如何在 swfobject.embedSWF 中使用 flashvars 属性?
Posted
技术标签:
【中文标题】如何在 swfobject.embedSWF 中使用 flashvars 属性?【英文标题】:How to use the flashvars attribute with swfobject.embedSWF? 【发布时间】:2011-10-13 05:21:21 【问题描述】:html:
<div class="playerFlashBox">
<object type="application/x-shockwave-flash" id="playerSWF" name="playerSWF" data="/flash/Player.swf" >
<param name="movie" value="/flash/Player.swf">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<param name="quality" value="high" />
<param name="wmode" value="opaque">
<param name="FlashVars" value="ProjectId=<%= @project.id.to_s %>&Language=<%= @locale %>" />
<embed type="application/x-shockwave-flash" id="playerSWF" name="playerSWF" src="/flash/Player.swf" class="playerBox"
allowScriptAccess="sameDomain"
allowFullScreen="true"
quality="high"
flashVars="ProjectId=<%= @project.id.to_s %>&Language=<%= @locale %>"
pluginspage="http://www.adobe.com/go/getflashplayer"
></embed>
</object>
</div>
<script type="text/javascript">
var flashvars =
"ProjectId=<%= @project.id.to_s %>&Language=<%= @locale %>"
;
var params =
allowScriptAccess: "sameDomain",
allowFullScreen: "true",
wmode: "opaque",
quality: "high",
menu: "false"
;
var attributes = ; attributes.styleclass="playerBox";
swfobject.embedSWF("/flash/Player.swf", "playerFlashBox", "800", "450", "9.0.0","expressInstall.swf", flashvars, params, attributes);
</script>
我想用一个干净的 swfobject 语句替换它。我只是不知道如何使用 flashvars 属性。有什么想法吗?
【问题讨论】:
您的参数名称有错误:PrOjectId 【参考方案1】:您将其创建为参数和属性之类的对象:
var flashvars =
PrjectId:"<%= @project.id.to_s %>",
Language:"<%= @locale %>"
;
【讨论】:
【参考方案2】:您可以通过以下方式从 flash 中提取变量:
var flashVars:Object = this.root.loaderInfo.parameters;
var projectId:String = flashVars["PrjectId"];
var language:String = flashVars["Language"];
【讨论】:
以上是关于如何在 swfobject.embedSWF 中使用 flashvars 属性?的主要内容,如果未能解决你的问题,请参考以下文章
如何检查是不是使用带有 swfobject 的 JavaScript 加载了 swf?