How to migrate SWFObject call code?
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("allowFullS开发者_运维问答creen", "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
);
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>
Also from the swfobject docs, it expects width and height to be strings, you have height as an int there.
精彩评论