actionscript 3 - flash as3 loader question -


What am I trying to do, loading 2 different SWFs using 2 different buttons?

What happens to me when this happens is that when you click on the 1 button it loads the SWF first and the second loads 2 removes any other SWF from the second swift stage.

I think the problem is running with the loader. I can not seem to load images in the loader without putting me on stage. And when I try to load the images dynamically, then it moves on the second one in the loader and again on the SWF, although I am using it:

  stage RemoveChild (loader); Loader = new loader ();  

Any help or tutorials on this information will be great.

I will use different loaders to load each. Here's a quick example of how you can implement it:

* Edit: This package is cutting off the part, please forgive me for understanding the code parser of Stackoverflow *

`Package

Import Flash.display.Loader; Import flash.display.Sprite; Import flash.events.Event; Import flash.events.MouseEvent; Import flash.net.URLRequest;

  Public class loads LoaderTest Sprite {// two loaders private var _firstLoader: loader = new loader (); Private var _secondLoader: Loader = new loader (); // Just assuming that you already have buttons that you want to setup, use them as theoretical buttons Private var _buttonOne: Sprite; Private var _buttonTwo: Sprite; Public Function Loader Test () {_firstLoader.contentLoaderInfo.addEventListener (event.complete, imageloaded); _secondLoader.contentLoaderInfo.addEventListener (event.complete, imageloaded); _firstLoader.load (new URLRequest ("path / to / image.jpg")); _secondLoader.load (new URLRequest ("path / to / image.jpg")); _buttonOne.addEventListener (MouseEvent.CLICK, showImage); _buttonTwo.addEventListener (MouseEvent.CLICK, showImage); } Private function imageLoaded (E: Event): Zero {// do something if you want} Private Function showImage (e: MouseEvent): zero {switch (e.target) {case_buttonOne: if (! (_firstLoader included) If ((_secondLoader) is included) (if ((_secondLoader) is) removeChild (_secondLoader); addChild (_firstLoader);} breakage; case _buttonTwo: if ((_secondLoader) is included) {if ((first fill loader)) removeChild (_firstLoader); addChild _secondLoader);} break;}}  

} `


Comments