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!

2009
07.09

Hey,
In this first tutorial today we are going to talk about how to use javascript to open a new browser window from flash.
The code that is required is fairly simple actually.

var request:String =
“javascript: window.open(‘http://www.sowebme.com/murtaza’,'win’,'height=400,width=600,toolbar=no,scrollbars=yes’); void(0)”;

var url:URLRequest = new URLRequest(request);

navigateToURL(url, “_self”);

Within your HTML housing the flash, you are going to need the parameter “AllowScriptAccess” set to “always”.

Feel free to download the working files here:
New Window Example