2009
07.09

Well there are many instances when we need to pass flashVars from the html to a preloader and then on to a loaded movieClip.

This is how I’ve done it.

HTML –

<param name=”FlashVars” value=”baseURL=http://www.sowebme.com/murtaza” />
For AC_RunActiveContent.js users, There should be 3 instances where you would place this
For swfObject users, there will be only once.

Flash –
holder mc will get the paramets from FlashVars in stage.loaderInfo.parameters.whatevernameditemhere

But a more robust way to ensure you have it and that you’ve not jumped the gun, use an event to ensure its ready.
An example is as follows:

root.loaderInfo.addEventListener(Event.COMPLETE, func);
var parameters:Object=new Object();
function func(e:Event):void {
//Do what you want here
}

Now to load another swf we will be using it to append to the current url we are already loading. So the above code will now look like

root.loaderInfo.addEventListener(Event.COMPLETE, func);
var parameters:Object=new Object();
var loader:Loader=new Loader();
function func(e:Event):void {
loader.load(new URLRequest(“loadme.swf?baseURL=”+root.loaderInfo.parameters.baseURL));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded);
addChild(loader);
}

function swfLoaded(e:Event):void {
//More code here
}

So that about sums up how you can use flashVars and pass them along. Note one thing though. If you are using classes, you can use stage.loaderInfo instead of root.loaderInfo

You can download the source file for passing flash vars

Have fun and please post your comments!

No Comment.

Add Your Comment