-
Simple loading/unloading .swf with embedded .flv via buttons
Greetings
I have created a simple flash file that loads 3 different external .swf's via the buttons that I created. These external .swf's load up with no problem but after I click the another button that relative .swf loads up on top of the other one or atleast the sound from the previous .swf is still playing. My question is, what is the easiest way to unload the current .swf entirely as I load the next one? I have attached my file.
Thanks!!!
-
sorry
the file exceeded the limit so I cannot attach what I needed to.
-
Senior Member
Unfortunately unloading does not work because of a bug, but you can delete the Loader and create a new one.
- The right of the People to create Flash movies shall not be infringed. -
-
thanks
What exactly do you mean delete the loader and create a new one. Is that within the script?
I have one content key frame with a container and three buttons on the stage. Then a key frame with the actionscript.
Here is my script:
var myLoader:Loader = new Loader();
container.addChild(myLoader);
one_bt.addEventListener(MouseEvent.CLICK, btn1Clicked);
function btn1Clicked(event:MouseEvent):void
{
var myURL:URLRequest = new URLRequest("movie.swf");
myLoader.load(myURL);
}
two_bt.addEventListener(MouseEvent.CLICK, btn2Clicked);
function btn2Clicked(event:MouseEvent):void
{
var myURL:URLRequest = new URLRequest("movietwo.swf");
myLoader.load(myURL);
}
three_bt.addEventListener(MouseEvent.CLICK, btn3Clicked);
function btn3Clicked(event:MouseEvent):void
{
var myURL:URLRequest = new URLRequest("moviethree.swf");
myLoader.load(myURL);
}
-
I think he means:
Code:
delete loader;
var loader:Loader = new Loader();
or
Code:
loader = null;
var loader:Loader = new Loader();
Dan
-
Senior Member
Thanks dan_hin
To delete the Loader object use removeChild(loader)
if(loader!=null)
{
removeChild(loader);
var loader:Loader = new Loader();
addChild(loader);
}
else
{
loader.load(request);
}
Something like this.
Otherwise actually if you have a loader and load something new it should replace the old movie or image. just do not create new loaders to have several loaders.
- The right of the People to create Flash movies shall not be infringed. -
-
Thanks
Thanks guys... y'all are very helpful. I understand that the one container that I have on the stage has to be either deleted or unloaded and then loaded again. I added the code to the end of my script and messed with it a bit but it received errors and I could not figure out exactly how I'm supposed to use it. Do I need to remove some previous script or edit the script that you gave me to some change.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|