PDA

View Full Version : Loading External swf file


Arby
02-29-2008, 06:22 PM
I am a newbie to the whole actionscript world. Almost at "Hello World!" stage. :). I am working on a prototype which loads one of the 2 swf files from a swf file randomly. Both my target swf files have just text. Here is the code in my source swf's actionscript:

public function RunApp():void
{
var intM:int = Math.round(Math.random()*2);
var url:String;
if(intM == 0)
{
url = "test1.swf";
}
else
{
url = "test2.swf";
}
var request:URLRequest = new URLRequest(url);
var loader:Loader;
loader = new Loader();
this.addChild(loader);
loader.load(request);
}

But this doesnt seem to load my target swf files.
I would really appreciate anyone helping me on this. Thanks in advance.

Arby
02-29-2008, 06:28 PM
FYI:
All the three swf files are in the same folder - source.swf, test1.swf and test2.swf.