Page 1 of 1

Actionscript 3 - loading an external swf at runtime

Posted: Tue Aug 19, 2008 10:53 am
by jaoudestudios
Hi All,

I have spent most of the day looking for a simple example of how to load an external swf file at runtime. :banghead:

Please can some one help.

I can embed it easily but I need to be able to change it. I am not worrying about making it dynamic now, I just want it to work as if it was (hope that makes sense).

I have tried various examples from simple to hard, I have ended up with this simple example that I would like to work...

Code: Select all

 
import mx.controls.SWFLoader;
public var myLoader:SWFLoader = new SWFLoader();
myLoader.load("example.swf");
 
Thanks :)

Re: Actionscript 3 - loading an external swf at runtime

Posted: Fri Aug 22, 2008 4:12 am
by Sindarin
Try this,
var request:URLRequest = new URLRequest("example.swf");
var loader:Loader = new Loader();

loader.load(request);
this.addChild(loader);

Re: Actionscript 3 - loading an external swf at runtime

Posted: Fri Aug 22, 2008 2:13 pm
by jaoudestudios
Thanks.

I solved it, the external swf file had to be created in CS3 to work.