Actionscript 3 - loading an external swf at runtime

Need help with Photoshop, the GIMP, Illustrator, or others? Want to show off your work? Looking for advice on your newest Flash stuff?

Moderator: General Moderators

Post Reply
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Actionscript 3 - loading an external swf at runtime

Post 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 :)
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Re: Actionscript 3 - loading an external swf at runtime

Post by Sindarin »

Try this,
var request:URLRequest = new URLRequest("example.swf");
var loader:Loader = new Loader();

loader.load(request);
this.addChild(loader);
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Actionscript 3 - loading an external swf at runtime

Post by jaoudestudios »

Thanks.

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