I need help me with the Loader.unloadAndStop

hi Expert;
I have 4 buttons in my main movie and each one of them load 4 different movies (Movie1.swf; Movie2.swf; Movie3.swf; Movie4.swf) into a Moviel Clip that I have set in my scene.
I just discovered that the problem is with the loader.unloadAndStop
I don't know where to put it in my code.
any help Thanks

I am using AS3
var thisMovieClip:MovieClip;
var thisLoader:Loader = new Loader();

function WhichMovieToPlay():void{
	 if(ButtonUnicValue == 1)   //if button 1 Have been click
		 thisLoader.load(new URLRequest("Movie1.swf"));
		 thisLoader.name = "Movie1";

	 if(ButtonUnicValue == 2)  //if button 2 Have been click
		 thisLoader.load(new URLRequest("Movie2.swf"));
		 thisLoader.name = "Movie2";

	 if(ButtonUnicValue == 3)  //if button 3 Have been click
		 thisLoader.load(new URLRequest("Movie3.swf"));
		 thisLoader.name = "Movie3";	 	

	 if(ButtonUnicValue == 4)  //if button 4 Have been click
		 thisLoader.load(new URLRequest("Movie4.swf"));
		 thisLoader.name = "Movie4";	
    thisLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, doneLoading);	
    var info:LoaderInfo = LoaderInfo(thisLoader.contentLoaderInfo)	 

function doneLoading(e:Event):void { 
  thisMovieClip = MovieClip(e.currentTarget.content);  

Open in new window

Who is Participating?
MontoyaConnect With a Mentor Process Improvement MgrCommented:
I'm actually away from my Mac with Flash, but here's the logic.

Create a function that unloads  your movie. Call that function before you load every new movie.

I would work out the logic like this:

Create a variable for the loaded movie:
When my application starts, my loaded movie variable will equal "none".

var loadedMovie = "none"  //if using AS2 or above, just add the type for the variable here:

Everytime a button is pressed:

if the movie loaded variable does not equal 'none', unload and stop "loadedMovie".
Very status of unloaded movie.
Now, load your new movie.
Change the value of "loadedMovie" to whatever your current movie is.

Wash/Rinse and Repeat :)

I hope this helps. I wont be near my machine for a few days, but ask away and I'll try to explain.

MontoyaProcess Improvement MgrCommented:
I'm trying to understand your problem. Are you saying that your application does not switch properly between the 4 movies?
eddyperuAuthor Commented:
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.