Jump to content
Search Community

Loading Multiple Swfs

el_barto test
Moderator Tag

Recommended Posts

Hi,

 

Is using the LoaderMax class the best thing to use for loading and unloading multiple external swfs into a dynamically created Sprite object?

 

I have created a simple Sprite object and added it to the stage using the conventional addChild(contentContainer) method but what I wanted to find out is, is there a way of using LoaderMax to load and unload (and remove them from the sprite) various swfs that I have created. As I'm fairly new to the LoaderMax way of working I have checked out the six or so video tutorials that give a great introduction to the LoaderMax class, have looked at the tips and tricks section too and have done some searching around in the forums to see if anyone else has asked the same or something similar to me.

 

I read that the good thing about using LoaderMax is that it can store multiple loaders in a queue, but are you able to then call those individual loaders one at a time depending on which ever swfs file you want to load or is it best to create and new SWFLoader instance for each swf file that I want to load in? I don't want to load all the swfs at once rather have the load in depending on which button the user clicks on. So say for example that when the user clicks on btn_1 whatever is in the sprite is removed and then swf_1 is loaded in. Then when they click btn_2 the contents of the sprite are removed and the new content, swf_2 is then loaded in and so on.

 

Sorry that this might sound really basic but any tips or pointers would be great?

Link to comment
Share on other sites

Sure, if you don't need to load a queue of swfs/images/whatever and/or report their progress as a whole, there's no need to dump your stuff into a LoaderMax instance. Just create individual SWFLoaders if you want. When you want to load new content, just dispose(true) the old SWFLoader and create a new one. Kinda like:

 

var swf:SWFLoader = new SWFLoader("1.swf", {container:mySprite});
swf.load();

function clickHandler(event:MouseEvent):void {
swf.dispose(true);
swf = new SWFLoader("2.swf", {container:mySprite});
swf.load();
}

 

You could reuse the same SWFLoader instance and just change the "url" property, but due to some bugs in Flash that could cause headaches if you try to do that while the old swf is still loading, I'd recommend creating a new SWFLoader each time.

 

Does that help?

Link to comment
Share on other sites

That helps a lot, thanks! I did come across the dispose() feature in the tutorial videos and wondered if that was how you removed a child from is parent but when your so used to coding it the old way it takes a while to get used to the new (and much simpler) way of doing the task.

 

Thanks again for your help and also your quick reply!

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.
×
×
  • Create New...