Jump to content


Dynamic creation

Recommended Posts

Is there a way to dynamically create SWFLoader vars at runtime?


I am about to start a project where I will need to load and unload a lot of external swfs.


So can I dynamically create:

var page1loader:SWFLoader = new SWFLoader("pages/page1.swf",{name:"p1",container:pagecontainer,onComplete:completeHandler});
var page2loader:SWFLoader = new SWFLoader("pages/page2.swf",{name:"p2",container:pagecontainer,onComplete:completeHandler});
var page3loader:SWFLoader = new SWFLoader("pages/page3.swf",{name:"p3",container:pagecontainer,onComplete:completeHandler});
var page4loader:SWFLoader = new SWFLoader("pages/page4.swf",{name:"p4",container:pagecontainer,onComplete:completeHandler});



If someone knows how, your friend I shall be.

Link to comment
Share on other sites

The most straight-forward way for me would be to create a loop that stores them in an array


var swfs_arr:Array = []

var numberOfLoaders:int = 5;

for( var i:int = 0; i        swfs_arr.push( new SWFLoader( "pages/page" + i + ".swf", {name:"p" + i", container:pagecontainer,onComplete:completeHandler}))



to tell the first SWFLoader to load:





also it might make more sense in your loop to just append them to a LoaderMax.



i look forward to our new friendship:)

Link to comment
Share on other sites

Would I be able to load the swf via:




Link to comment
Share on other sites

you would want to do:



Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.