Missing FlashVars in Flash Professional CS5 and swfobject?
I have a Flash Professional CS5 movie which I'm trying to pass a parameter with swfobject. The problem is that movieclip's flashvar variables (under loaderInfo.parameters) is null.
Here is the swfobject code:
function loadSetupBar(connectId)
{
// add the setup bar to the DOM using swfobject
swfobject.embedSWF("{{setupBarSwf}}",
"swf-setup-bar",
{{gameWidth}}, $("#top-bar").height(),
"10.0.0", "{{installSwf}}",
{connectionId : connectId },
{
allowFullScreen : true,
wmode : 'opaque',
allowscriptaccess: "always"
},
{name:"swf-setup-bar"}
);
}
According to the swfobject documentation, everything seems to be ok.
Here's the corresponding code inside the FLA (A MovieClip with its own AS3 class):
var params : Object = root.loaderInfo.parameters;
var conn开发者_JAVA技巧ectionId : String = params.connectionId;
if ( !params.hasOwnProperty('connectionId') )
// this line is always printed.
trace("[SetupBar-Error] loaderInfo parameters missing property 'connectionId'")
I'm not sure about what else to do.
Thanks.
EDIT: Here is a list of things I've tried that have failed:
- casted root.loaderInfo to class LoaderInfo ( i.e. LoaderInfo(this.root.loaderInfo) )
- passing a String literal in swfobject.embedSWF instead of param connectId (i.e. {connectionID : 'myTestValue'})
There's a problem with the TLF TEXT control, when you add it to the stage the flashvars begins not working . just don't use it and your flashvars will work fine . i've faced the same problem and i got it solved by not using TLF TEXT control.
I hope i helped .
Best Regards
Try this:
var params:Object = LoaderInfo(this.root.loaderInfo).parameters;
var connectionID:String = params.connectionId;
精彩评论