Share Posted May 31, 2011 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}); ...ect If someone knows how, your friend I shall be. Link to comment Share on other sites More sharing options...
Share Posted May 31, 2011 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: swfs_arr[0].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 More sharing options...
Author Share Posted June 1, 2011 Would I be able to load the swf via: page1loader.load(); ? Link to comment Share on other sites More sharing options...
Share Posted June 1, 2011 you would want to do: LoaderMax.getLoader("p1").load Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now