如何在swfobject.embedSWF中使用flashvars属性?

时间:2011-07-26 08:27:16

标签: javascript flash swfobject

HTML:

<div class="playerFlashBox">
    <object width="800" height="450" 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 %>&amp;Language=<%= @locale %>" />
        <embed width="800" height="450" 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 %>&amp;Language=<%= @locale %>"
            pluginspage="http://www.adobe.com/go/getflashplayer"
        ></embed>
    </object>
</div>

使用Javascript:

<script type="text/javascript">
    var flashvars = {
        "ProjectId=<%= @project.id.to_s %>&amp;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属性。有什么想法吗?

2 个答案:

答案 0 :(得分:4)

您将其创建为对象,如params和属性:

var flashvars = {
    PrjectId:"<%= @project.id.to_s %>",
    Language:"<%= @locale %>"
};

答案 1 :(得分:1)

从闪光灯中你可以通过以下方式拉起变种:

var flashVars:Object = this.root.loaderInfo.parameters;
var projectId:String = flashVars["PrjectId"];
var language:String = flashVars["Language"];