如何迁移SWFObject调用代码?

发布于 2024-09-06 20:01:17 字数 908 浏览 2 评论 0原文

我有这样的旧代码,它使用旧版本的 SWFObject.js 将 SWF 嵌入到 HTML 中:

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");

我应该如何为最新的 SWFObject.js 重写它?我已经尝试过但失败了,我想首先排除语法不匹配的情况:

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
); 

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
); 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

つ可否回来 2024-09-13 20:01:17

嗯,我当然认为这会起作用。基本上,flashvars、params 和 attribute 需要是 js 对象。我通常将它们保留为单独的对象,而不是像您设置的那样使用单个对象。

<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>

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>
花开柳相依 2024-09-13 20:01:17

同样从 swfobject 文档中,它期望宽度和高度是字符串,你在那里有一个 int 高度。

Also from the swfobject docs, it expects width and height to be strings, you have height as an int there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文