Unload swf movie AS2 inside swf AS3

Hi
I'm using Flash CS3 with Action Script 3, and I load a movie in AS2 insede another movie in AS3.
The code is
var contenedor = new Loader();
contenedor.load(new URLRequest("05_01_menu.swf"));
addChild(contenedor);
contenedor.x = 180
contenedor.y = 288

I don't know how to unload the movie to see the rest of the movie free and load another movies.

Thanks
yomientoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

blue-genieCommented:
unload () method  

public function unload():void

Language Version :  ActionScript 3.0
Player Version :  Flash Player 9



Removes a child of this Loader object that was loaded by using the load() method. The property of the associated LoaderInfo object is reset to null. The child is not necessarily destroyed because other objects might have references to it; however, it is no longer a child of the Loader object.

As a best practice, before you unload a child SWF file, you should explicitly close any streams in the child SWF file's objects, such as LocalConnection, NetConnection, NetStream, and Sound objects. Otherwise, audio in the child SWF file might continue to play, even though the child SWF file was unloaded. To close streams in the child SWF file, add an event listener to the child that listens for the unload event. When the parent calls Loader.unload(), the unload event is dispatched to the child. The following code shows how you might do this:

function closeAllStreams(evt:Event) {
    myNetStream.close();
    mySound.close();
    myNetConnection.close();
    myLocalConnection.close();
}

myMovieClip.loaderInfo.addEventListener(Event.UNLOAD, closeAllStreams);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yomientoAuthor Commented:
Hi . I can't understand your answer. I a begeaner in Flash.

What I have to erase and what I have to put?
At the frame 106 I wrote this

var contenedor = new Loader();
contenedor.load(new URLRequest("05_01_menu.swf"));
addChild(contenedor);
contenedor.x = 180
contenedor.y = 288

And I would like to unload that movie on frame 111

I'd try to attach a .zip with the flash movie file the system didn't permited
Can you help me?
Thanks
0
blue-genieCommented:
you asked how to unload a movie.

contenedor.unloadMovie()
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

yomientoAuthor Commented:
Yes but I'm using AS3, and that doesn't work.
I would like to know how to unload a movie made in AS2 who was loaded in a previous frame with this script

var contenedor = new Loader();
contenedor.load(new URLRequest("05_01_menu.swf"));
addChild(contenedor);
contenedor.x = 180
contenedor.y = 288
0
blue-genieCommented:
arrgh its unload not unloadMovie as per my first post not my second one.
if you simply want to remove the loader and hence the content you can use removeChild.
0
fsilva79Commented:
I have the same problem, can anyone help us please?

Blue-genie:
I totaly understand the idea you are showing in:
function closeAllStreams(evt:Event) {
    myNetStream.close();
    mySound.close();
    myNetConnection.close();
    myLocalConnection.close();
}

myMovieClip.loaderInfo.addEventListener(Event.UNLOAD, closeAllStreams);

but my problem is that I want to know if your variable "myMovieClip" is actually the varible :Loader
or what type of variable is it?
0
fsilva79Commented:
ok, I found the solution and here it is how I managed to do it

ok, finaly I manage to solve this problem, i did the following:

import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundMixer;
 
var loader:Loader = new Loader(); //this variable will load the file
var movieClip:MovieClip = new MovieClip();
 
...(your code here)
...(your code here)
...(your code here)
 
//then... i wrote my CloseButton function as follows:
 
private function closeMovieClip(evt:MouseEvent):void
{
	var movieClip:MovieClip = MovieClip(evt.currentTarget);
	movieClip.removeEventListener(MouseEvent.DOUBLE_CLICK, closeMovieClip);
	Tweener.removeTweens(movieClip);
		
	if(contains(movieClip))
		removeChild(movieClip);
		SoundMixer.stopAll();
		loader.unload();
}
/* the only downside of this is that if you had a background sound playing this command will stop ALL your sounds, special efects, music, whatever your flash is playing.*/

Open in new window

0
blue-genieCommented:
close your question please.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.