Solved

I need help me with the Loader.unloadAndStop

Posted on 2010-11-19
3
473 Views
Last Modified: 2012-08-13
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);  
  loadDemo_mc.addChild(thisMovieClip);
  loadDemo_mc.addEventListener(Event.ENTER_FRAME,runOnce);
   
}

Open in new window

0
Comment
Question by:eddyperu
  • 2
3 Comments
 
LVL 19

Expert Comment

by:Montoya
ID: 34176290
I'm trying to understand your problem. Are you saying that your application does not switch properly between the 4 movies?
0
 
LVL 19

Accepted Solution

by:
Montoya earned 500 total points
ID: 34176353
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.

var
0
 
LVL 4

Author Closing Comment

by:eddyperu
ID: 34283406
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
flash cs6 4 345
Video sharing with user login 3 198
Flash player updates using SCCM 2012 and SCUP 2011 3 391
good online free meeting tool with record audio video feature 2 132
This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now