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?
 
blue-genieConnect With a Mentor Commented:
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
 
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.