Question

I want to get FlashVars in my html using action script,

the < OBJECT > tag in html like:

            <!--[if !IE]>-->
            <object type="application/x-shockwave-flash" data="test.swf" width="550" height="400">
                <param name="movie" value="test.swf" />
                <param name="quality" value="high" />
                <param name="bgcolor" value="#ffffff" />
                <param name="play" value="true" />
                <param name="loop" value="true" />
                <param name="wmode" value="window" />
                <param name="scale" value="showall" />
                <param name="menu" value="true" />
                <param name="devicefont" value="false" />
                <param name="salign" value="" />
                <param name="allowScriptAccess" value="sameDomain" />
                <param name="FlashVars" value="acc=3001&pwd=test">
            <!--<![endif]-->
                <a href="http://www.adobe.com/go/getflash">
                    <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" />
                </a>
            <!--[if !IE]>-->
            </object>
            <!--<![endif]-->

and my action script is use as a model in flex that used by mxml, so I don't have movieclip or I cannot use this.loaderInfo.parameters; or root since there isn't a displayObject.

Is there other method to grab the FlashVars value in as3,

or can I get FlashVars in mxml then let as3 get the variable such as:

var paramObj:Object = Application(FlexGlobals.topLevelApplication).parameters;
var test:String;
test = paramObj['acc'];

and in as3:

var getText:String = test;

Thanks in advance.

Was it helpful?

Solution

You will have access to the FlexGlobals anywhere in the application since the topLevelApplication is static type, it could be even in the AS file. So, instead of doing that in the MXML file, you could do that in the AS file itself

OTHER TIPS

I use Application.application.parameters finally! It is strange I use Flex 4.6 SDK but my Flex version is 2, so I cannot use FlexGlobals. The result is similar to using FlexGlobals:

In your html:

<script type="text/javascript">
            // For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. 
            var swfVersionStr = "11.1.0";
            // To use express install, set to playerProductInstall.swf, otherwise the empty string. 
            var xiSwfUrlStr = "playerProductInstall.swf";
            var flashvars = {};
            var params = {};
            params.quality = "high";
            params.bgcolor = "#ffffff";
            params.allowscriptaccess = "sameDomain";
            params.allowfullscreen = "true";
            params.FlashVars = "acc=3001&pwd=test";

and import mx.core.Application;

then use the code in actionscript or mxml:

Application.application.parameters.acc;

and above result will be 3001.

I also try to add <param name="acc=3001&pwd=test"> but the actionscript cannot understand it( the result is undefined), I not sure why though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top