views:

18

answers:

1

I have this legacy code which embeds an SWF into an HTML using an old version of SWFObject.js:

var so = new SWFObject("main.swf", "main", "100%", "615", "9.0.115", "#000000");
so.addVariable("deeplink", deeplink);
so.addVariable("cid", cid);
so.addParam("scaleMode", "noscale");
so.addParam("allowScriptAccess", "always");
so.addParam("allowFullScreen", "true");
so.write("flashcontent");

How should I rewrite it for the latest SWFObject.js? I have tried this but failed, and I would like to rule out the syntax-mismatch first:

var mainSwfProperties = {
    flashVars : {
        cid : cid,
        deeplink : deeplink
    },
    params : {
        allowFullScreen : "true",
        allowScriptAccess : "true",
        scaleMode : "noscale",
        wmode : "window"
    },
    attributes : {}
};
swfobject.embedSWF("main.swf", "flashcontent", "100%", 615, "9.0.115", null,
    mainSwfProperties.flashVars,
    mainSwfProperties.params,
    mainSwfProperties.attributes
); 
+1  A: 

Well, I would certainly think that would work. Basically, the flashvars, params, and attributes need to be js objects. I usually leave them as separate objects rather than having a single object like you have set uo.

<script type="text/javascript">
    var flashvars = {cid:cid, deeplink:deeplink};
    var params = {allowFullScreen:true, allowScriptAccess:true, scaleMode:"noscale", wmode:"window"};
    var attributes = {}
    swfobject.embedSWF("main.swf", "flashcontent", "100%", "615", "9.0.115", null, flashvars, params, attributes);
</script>
sberry2A