How to use the flashvars attribute with swfobject.embedSWF?

13,549

Solution 1

you create it as an object like the params and attributes:

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

Solution 2

From flash you can pull up the vars by doing:

var flashVars:Object = this.root.loaderInfo.parameters;
var projectId:String = flashVars["PrjectId"];
var language:String = flashVars["Language"];
Share:
13,549
matt
Author by

matt

Updated on June 28, 2022

Comments

  • matt
    matt almost 2 years

    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>
    

    I want to replace this with a clean swfobject statement. I just have no clue how to work with the flashvars attribute. Any ideas?