SwfAddress Conflicts With SwfObject Callback Argument

For the current project, we are using SwfObject 2.2 to embed flash files, and the CRD gurus are using SwfAddress 2.3 to create good SEO quality.

It turns out that if you have both libraries included in the page, then any attempts to use the SwfObject callback in the API ( http://code.google.com/p/swfobject/wiki/api ) prevents the SwfObject from loading. In this example, you can toggle this just HTML by commenting out the SwfAddress.

Sorry, I cannot provide absolute urls for these two libraries in my code below.

<head>
    <title>SWFObject 2.2 dynamic embed with callback</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <script type="text/javascript" src="swfobject.js"></script>
    <script type="text/javascript" src="swfaddress.js"></script>
    <script type="text/javascript">
    function outputStatus(e) {
        alert("e.success = " + e.success +"\ne.id = "+ e.id +"\ne.ref = "+ e.ref);
    }
    var params = {};
    params.allowscriptaccess = "always";

    swfobject.embedSWF("http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test6.swf", "myContent1", "300", "120", "9.0.0", "expressInstall.swf", null, null);
    swfobject.embedSWF("http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test6.swf", "myContent2", "300", "120", "9.0.0", "expressInstall.swf", null, params, null, outputStatus);
    </script>
</head>

<body>
    <div id="myContent1">
        <h1>Alternative content</h1>
        <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
    </div>
    <div id="myContent2">
        <h1>Alternative content</h1>
        <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
    </div>
</body>

      

Any ideas? Thanks in advance!

+2


source to share


1 answer


It was complicated.

Quick answer: you need to pass empty objects instead of "null" for flashVars and attributes: ( Check out my corrected demo code here )

swfobject.embedSWF("http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test6.swf", "myContent1", "300", "120", "9.0.0", "expressInstall.swf", {}, {});
swfobject.embedSWF("http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test6.swf", "myContent2", "300", "120", "9.0.0", "expressInstall.swf", {}, params, {}, outputStatus);

      



Full answer. Digging into the SWFAddress source code, they rewrite the embedding functionality of SWFObject so they can inject their own. One of the things they have to do for this is to pass all the parameters you pass into their own function. The "Null" you passed for the attributes object was causing an error in the SWFAddress code here:

var _s2e = swfobject.embedSWF;
    swfobject.embedSWF = function() {
    _args = arguments;
    if (typeof _args[8] == UNDEFINED)
        _args[8] = {};
    if (typeof _args[8].id == UNDEFINED)
        _args[8].id = _args[1];  // <-- ERROR here when this parameter (attributes) is null.
        _s2e.apply(this, _args);
        _ref.addId(_args[8].id);
    }

      

The error caused the entire second insert to fail.

+2


source







All Articles