Skip to content
This repository has been archived by the owner on Mar 23, 2019. It is now read-only.

FABridge does not find flash object in Chrome #131

Open
geniot opened this issue Dec 1, 2012 · 1 comment
Open

FABridge does not find flash object in Chrome #131

geniot opened this issue Dec 1, 2012 · 1 comment

Comments

@geniot
Copy link

geniot commented Dec 1, 2012

When trying to use JS to Flash communication using FABridge , FABridge doesn't find flash object.
Fix is described at http://www.timothyhuertas.com/blog/2010/11/30/fabridgejs-play-nice-with-chrome/
I'm not sure whether you need to update FABridge version or make this change in your version of FABridge. Your current latest version 1.5.1 contains flawed FABridge which doesn't find Chrome.

@icacho-dev
Copy link

Same Error here in Chrome:
2fae5229609969e4ebaa2db933948dcbc009464f28 1

Uncaught TypeError: Cannot call method 'root' of undefined myHTML.html:33
onClick myHTML.html:33

Same code in Internet Explorer and Firefox works fine.

SOLVED:

Just go to: IFrameCommTest/bin-debug/bridge/FABridge.js and replace the FABridge__bridgeInitialized function with this code:

function FABridge__bridgeInitialized(bridgeName) {
    var searchStr = "bridgeName=" + bridgeName;
    var flashInstanceWithBridge = null;

    var flashInstances = document.getElementsByTagName("object");

    //search object tag
    if (flashInstances.length == 1) {
        flashInstanceWithBridge = flashInstances[0];
    } else {
        for (var i = 0; i < flashInstances.length; i++) {
            var inst = flashInstances[i];
            var params = inst.childNodes;
            var flash_found = false;

            for (var j = 0; j < params.length; j++) {
                var param = params[j];
                if (param.nodeType == 1 && param.tagName.toLowerCase() == "param") {
                    if (param["name"].toLowerCase() == "flashvars" && param["value"].indexOf(searchStr) >= 0) {
                        flashInstanceWithBridge = inst;
                        flash_found = true;
                        break;
                    }
                }
            }

            if (flash_found) {
                break;
            }
        }
    }

    if (!flashInstanceWithBridge || !flashInstanceWithBridge["getRoot"] || !( typeof (flashInstanceWithBridge.getRoot) == "function"))//search embed tag if the object tag does not have the needed methods
    {
        flashInstanceWithBridge = null;

        flashInstances = document.getElementsByTagName("embed");
        if (flashInstances.length == 1) {
            flashInstanceWithBridge = flashInstances[0];
        } else {
            for (var i = 0; i < flashInstances.length; i++) {
                var inst = flashInstances[i];
                var flashVars = inst.attributes.getNamedItem("flashVars").nodeValue;

                if (flashVars.indexOf(searchStr) >= 0) {
                    flashInstanceWithBridge = inst;
                }

            }
        }
    }

    if (flashInstanceWithBridge) {
        FABridge.attachBridge(flashInstanceWithBridge, bridgeName);
    }

    return true;
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants