Solved

Do I need to clean a"Loader" If I need to load a new movie?

Posted on 2010-11-11
13
367 Views
Last Modified: 2012-05-10
hi Expert;
I have 4 buttons and each one of them load 4 different movies "Movie1.swf; Movie2.swf; Movie3.swf; Movie4.swf" into a Moviel Clip that I have in scene.

Problem.
The movie clip in scene plays not only the movie that have been selected but also movies that have been selected in the past.
Do I need to clean the loader or the movie clip in scene before I load or display another movie?

Thanks

ps:I am using Action script 3

eddy


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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 34116545
Why don't you do something like the following:

<code>

Something like that should work, but if it doesn't, I'd ask you to post your fla so I can take a look at it.

Good Luck,

-V
var thisMovieClip:MovieClip;
var thisLoader:Loader = new Loader();

function WhichMovieToPlay():void{
	 	 
		 thisLoader = new Loader();        
         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 {
  loadDemo_mc.addChild(thisLoader);
  loadDemo_mc.addEventListener(Event.ENTER_FRAME,runOnce);  
}

Open in new window

0
 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 34146233
So.... did you get a chance to try this?

-V
0
 
LVL 4

Author Comment

by:eddyperu
ID: 34175771
Hi Vulturous,
I tried  your suggestion but but it didn't work.
I know what is the problem. It has something to do with the Loader.unloadAndStop.
I know I need to set it up in my code but I don't know where?

Ps: This is a note for the manager: I didn't see this question in my grid when I opened exchange,so I thought that someone took it out that is the reason why I created another question with more details,

Vulturous sorry about this; this is the other  question that I have created with the same topic
http://www.experts-exchange.com/Software/Photos_Graphics/Web_Graphics/Macromedia_Flash/Q_26627695.html

0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 34176085
How about something like this?

import flash.display.MovieClip;
import flash.display.Loader;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.events.Event;

var mcLoader:Loader = new Loader();

btnLoad1.movie = "Movie1.swf";
btnLoad1.addEventListener(MouseEvent.CLICK, playMovie);
btnLoad2.movie = "Movie2.swf";
btnLoad2.addEventListener(MouseEvent.CLICK, playMovie);
btnLoad3.movie = "Movie3.swf";
btnLoad3.addEventListener(MouseEvent.CLICK, playMovie);
btnLoad4.movie = "Movie4.swf";
btnLoad4.addEventListener(MouseEvent.CLICK, playMovie);

function playMovie(event:MouseEvent):void {
	mcLoader.unloadAndStop();
	mcLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, doneLoading);
	mcLoader.load(new URLRequest(event.currentTarget.movie));
}

function doneLoading(event:Event):void {
	addChild(mcLoader);
	addEventListener(Event.ENTER_FRAME, runOnce);
}

function runOnce(event:Event):void {
	if(event.currentTarget.currentFrame == event.currentTarget.totalFrames) {
		//last frame reached... do something here
	}
}

Open in new window


It's something kinda different but stops any audio playing in the loaded movies. You can download a sample on the attachment.

Loader-AS3.zip

And about the other question... if this one answers it, maybe you could just delete the other one.

Good luck.

-V
0
 
LVL 4

Author Comment

by:eddyperu
ID: 34176271
I got this error every time that I am using the unloadAndStop

1061: Call to a possibly undefined method unloadAndStop through a reference with static type flash.display:Loader.
0
 
LVL 4

Author Comment

by:eddyperu
ID: 34176364
I am uploading the main as3 file here. let me know if this help.

The idea is to create a customize player that can load swf files and then control it with play,stop, rewind and forward.
There are 6 buttons, and each one of them load a different swf file into  the container.

There is one MAIN movie that is the default one "MainEnrollmentMovie.swf" meaning that when the movie start running, this one is the one that will play until somone click any of the other buttons.

I need to unloadAndStop the container every time that a movie is load but my question is how???

by hte way, Thanks for all your help

Kind regards,
eddy
var addPause1:addPause = new addPause();
var c:int =0;
var o:int =0;
var WhoLoadingMovie:int =0;
var LoadingVariable:Number =0;
var LoadingTimeLite:Number =0;

var thisMovieClip:MovieClip;
var thisLoader:Loader = new Loader();


WhoisInside();
function WhoisInside():void{
	
	
	 if(WhoLoadingMovie == 0){
		 thisLoader.unloadAndStop();
		 thisLoader.load(new URLRequest("MainEnrollmentMovie.swf"));
		 thisLoader.name = "MainMovie";
		 LoadingVariable = 11.90;
		 LoadingTimeLite = 640;
	 }
	 if(WhoLoadingMovie == 1)
	 {
 		 thisLoader.unloadAndStop();
		 thisLoader.load(new URLRequest("Life.swf"));
		 thisLoader.name = "LongTermDisability";
		 LoadingVariable = 1.35;
		 LoadingTimeLite = 640;		 
		 WhoLoadingMovie = 0;
	 }		
	 if(WhoLoadingMovie == 2)
	 {
 		 thisLoader.unloadAndStop();
		 thisLoader.load(new URLRequest("ShortTermDisability2.swf"));
		 thisLoader.name = "ShortTermDisability";
		 LoadingVariable = .95;
		 LoadingTimeLite = 640;		 
		 WhoLoadingMovie = 0;
	 }	 
	 if(WhoLoadingMovie == 3)
	 {
		 thisLoader.load(new URLRequest("IndividualShortTermDisability.swf"));
		 thisLoader.name = "IndiVidualShortTermDisability";
		 LoadingVariable = 1.35;
		 LoadingTimeLite = 640;		 
		 WhoLoadingMovie = 0;
	 }		
	 if(WhoLoadingMovie == 4)
	 {
		 thisLoader.load(new URLRequest("Accident.swf"));
		 thisLoader.name = "Accident";
		 LoadingVariable = .95;
		 LoadingTimeLite = 640;		 
		 WhoLoadingMovie = 0;
	 }	 
	 if(WhoLoadingMovie == 5)
	 {
		 thisLoader.load(new URLRequest("LongTermDisability2.swf"));
		 thisLoader.name = "LongTermDisability";
		 LoadingVariable = .95;
		 LoadingTimeLite = 640;		 
		 WhoLoadingMovie = 0;
	 }		
	 
	 if(WhoLoadingMovie == 6)
	 {
		 thisLoader.load(new URLRequest("CriticalIllness.swf"));
		 thisLoader.name = "CriticalIllness";
		 LoadingVariable = 1.15;
		 LoadingTimeLite = 640;		 
		 WhoLoadingMovie = 0;
	 }			 
    thisLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, doneLoading);	
    var info:LoaderInfo = LoaderInfo(thisLoader.contentLoaderInfo)	 
    //trace(info.loaderURL);OnlySWFDemoCopy.fla
	//trace(thisLoader.name);

}


function doneLoading(e:Event):void { 
  thisMovieClip = MovieClip(e.currentTarget.content);  
  loadDemo_mc.addChild(thisMovieClip);
  loadDemo_mc.addEventListener(Event.ENTER_FRAME,runOnce);
   
}

function runOnce(event:Event):void{
    //trace(thisMovieClip.demo_mc.currentFrame);OnlySWFDemoCopy
	c = thisMovieClip.demo_mc.currentFrame;
	o = thisMovieClip.demo_mc.totalFrames;	
	var Result:Number = o/.21;
   // trace(Result);
	//trace("timeNumer: "+c+" LoadingVariable: "+o);
}


TimeLine_mc.buttonMode=true;
TimeLine_mc.addEventListener("click",getDistance,false,0,true);
function getDistance(event:Event):void{
         var timeNumer:int = int(event.currentTarget.mouseX); 
		 var SetTimeLine:int = int(timeNumer*LoadingVariable);
		 trace(SetTimeLine/10);
         thisMovieClip.demo_mc.gotoAndPlay(SetTimeLine);
		 
}

TimeLine_mc.InsideTimeLine_mc.addEventListener("enterFrame",showProgress);
function showProgress(event:Event):void{
       // var c:int = thisMovieClip.demo_mc.currentFrame;
        //var o:int = thisMovieClip.demo_mc.totalFrames;
        var p:Number = c/o;
		//trace(p);
		//trace("C: "+c+ " O: "+o);
		//trace(p);
        TimeLine_mc.InsideTimeLine_mc.width = LoadingTimeLite * p;
		if(p == 1){
		  closeEveything();
		}
}


PlayMovie_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandlerPlay);
PlayMovie_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandlerPlay);
PlayMovie_mc.addEventListener(MouseEvent.CLICK, PlayMovie);
PlayMovie_mc.buttonMode= true;
PlayMovie_mc.useHandCursor = true;
function onRollOverHandlerPlay(event:MouseEvent):void{
	PlayMovie_mc.gotoAndPlay("over");	
}

function onRollOutHandlerPlay(event:MouseEvent):void{
	PlayMovie_mc.gotoAndPlay("out");	

}

function PlayMovie(event:MouseEvent):void {

	thisMovieClip.demo_mc.play();		
	doesHaveAchild();
	thisMovieClip.demo_mc.removeEventListener("enterFrame",rewindHandler);
	stage.frameRate = 21;
}

StopMovie_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandlerStop);
StopMovie_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandlerStop);	
StopMovie_mc.addEventListener(MouseEvent.CLICK, StopMovie);
StopMovie_mc.buttonMode= true;

function StopMovie(event:MouseEvent):void {
	thisMovieClip.demo_mc.stop();	
	thisMovieClip.demo_mc.Pausing_mc.addChild(addPause1);
	thisMovieClip.demo_mc.removeEventListener("enterFrame",rewindHandler);
	
}	
function onRollOverHandlerStop(event:MouseEvent):void{
	StopMovie_mc.gotoAndPlay("over");	
}
function onRollOutHandlerStop(event:MouseEvent):void{
	StopMovie_mc.gotoAndPlay("out");	
}

function doesHaveAchild():void{
	if(thisMovieClip.demo_mc.Pausing_mc.numChildren != 0){		
		thisMovieClip.demo_mc.Pausing_mc.removeChild(addPause1);
	   }
}

RewindComplete_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandlerRewind);
RewindComplete_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandlerRewind);
RewindComplete_mc.addEventListener("click",startRewind,false,0,true);
RewindComplete_mc.buttonMode= true;
function startRewind(event:Event):void{
      thisMovieClip.demo_mc.stop();
      thisMovieClip.demo_mc.addEventListener("enterFrame",rewindHandler);
	  stage.frameRate = 60;
}
function rewindHandler(event:Event):void{
      thisMovieClip.demo_mc.prevFrame();		
}

function onRollOverHandlerRewind(event:MouseEvent):void{
	RewindComplete_mc.gotoAndPlay("over");	
}
function onRollOutHandlerRewind(event:MouseEvent):void{
	RewindComplete_mc.gotoAndPlay("out");	
}


forwardComplete_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandlerForward);
forwardComplete_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandlerForward);
forwardComplete_mc.addEventListener("click",resumePlay,false,0,true);
forwardComplete_mc.buttonMode= true;
function resumePlay(event:Event):void{
        if(thisMovieClip.demo_mc.hasEventListener("enterFrame")) 
		thisMovieClip.demo_mc.removeEventListener("enterFrame",rewindHandler);
        thisMovieClip.demo_mc.play();
        stage.frameRate = 60;
}
function onRollOverHandlerForward(event:MouseEvent):void{
	forwardComplete_mc.gotoAndPlay("over");	
}
function onRollOutHandlerForward(event:MouseEvent):void{
	forwardComplete_mc.gotoAndPlay("out");	
}


function closeEveything():void{
	thisMovieClip.demo_mc.stop();
}

login_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandlerl);
login_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandlerl);
login_mc.addEventListener(MouseEvent.CLICK, LoginSection);
login_mc.buttonMode = true;
login_mc.useHandCursor = true;

function onRollOverHandlerl(event:MouseEvent):void{
	login_mc.gotoAndPlay("over");	
}
function onRollOutHandlerl(event:MouseEvent):void{
	login_mc.gotoAndPlay("out");	
}
function LoginSection(event:MouseEvent):void{	
  if( thisLoader.name != "MainMovie")
     	WhoisInside();
   else
   {
	  thisMovieClip.demo_mc.gotoAndPlay("login");	
	  doesHaveAchild();	
  }
	
}


Welcome_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler);
Welcome_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler);
Welcome_mc.addEventListener(MouseEvent.CLICK, WelcomeSection);
Welcome_mc.buttonMode = true;
Welcome_mc.useHandCursor = true;

function onRollOverHandler(event:MouseEvent):void{
	Welcome_mc.gotoAndPlay("over");	
}
function onRollOutHandler(event:MouseEvent):void{
	Welcome_mc.gotoAndPlay("out");	
}
function WelcomeSection(event:MouseEvent):void{	
  if( thisLoader.name != "MainMovie")
     	WhoisInside();
   else
   {
	  thisMovieClip.demo_mc.gotoAndPlay("welcome");	
	  doesHaveAchild();	
  }
	
}



Learn_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler1);
Learn_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler1);
Learn_mc.addEventListener(MouseEvent.CLICK, LearnPage);
Learn_mc.buttonMode = true;
Learn_mc.useHandCursor = true;

function onRollOverHandler1(event:MouseEvent):void{
	Learn_mc.gotoAndPlay("over");	
}
function onRollOutHandler1(event:MouseEvent):void{
	Learn_mc.gotoAndPlay("out");	
}   
function LearnPage(event:MouseEvent):void{	
	thisMovieClip.demo_mc.gotoAndPlay("LearnPage");	
	doesHaveAchild();	
}




GetQuote_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler2);
GetQuote_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler2);
GetQuote_mc.addEventListener(MouseEvent.CLICK, GetAQuote);
GetQuote_mc.buttonMode = true;
GetQuote_mc.useHandCursor = true;

function onRollOverHandler2(event:MouseEvent):void{
	GetQuote_mc.gotoAndPlay("over");	
}
function onRollOutHandler2(event:MouseEvent):void{
	GetQuote_mc.gotoAndPlay("out");	
}
function GetAQuote(event:MouseEvent):void{	
	thisMovieClip.demo_mc.gotoAndPlay("GetAQuote");	
	doesHaveAchild();	
}




CompleteApplication_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler3);
CompleteApplication_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler3);
CompleteApplication_mc.addEventListener(MouseEvent.CLICK, CompleteApplication);
CompleteApplication_mc.buttonMode = true;
CompleteApplication_mc.useHandCursor = true;

function onRollOverHandler3(event:MouseEvent):void{
	CompleteApplication_mc.gotoAndPlay("over");	
}
function onRollOutHandler3(event:MouseEvent):void{
	CompleteApplication_mc.gotoAndPlay("out");	
}
function CompleteApplication(event:MouseEvent):void{
	
	thisMovieClip.demo_mc.gotoAndPlay("CompleteApplication");	
	doesHaveAchild();	
}



AddBeneficiarie_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler4);
AddBeneficiarie_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler4);
AddBeneficiarie_mc.addEventListener(MouseEvent.CLICK, AddBeneficiaries);
AddBeneficiarie_mc.buttonMode = true;
AddBeneficiarie_mc.useHandCursor = true;

function onRollOverHandler4(event:MouseEvent):void{
	AddBeneficiarie_mc.gotoAndPlay("over");	
}
function onRollOutHandler4(event:MouseEvent):void{
	AddBeneficiarie_mc.gotoAndPlay("out");	
}
function AddBeneficiaries(event:MouseEvent):void{
	
	thisMovieClip.demo_mc.gotoAndPlay("AddBeneficiaries");	
		doesHaveAchild();
}



ReviewDocument_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler5);
ReviewDocument_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler5);
ReviewDocument_mc.addEventListener(MouseEvent.CLICK, ReviewDocuments);
ReviewDocument_mc.buttonMode = true;
ReviewDocument_mc.useHandCursor = true;

function onRollOverHandler5(event:MouseEvent):void{
	ReviewDocument_mc.gotoAndPlay("over");	
}
function onRollOutHandler5(event:MouseEvent):void{
	ReviewDocument_mc.gotoAndPlay("out");	
}
function ReviewDocuments(event:MouseEvent):void{
	
	thisMovieClip.demo_mc.gotoAndPlay("ReviewDocuments");	
	doesHaveAchild();
}



SignApplication_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler6);
SignApplication_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler6);
SignApplication_mc.addEventListener(MouseEvent.CLICK, SignApplication);
SignApplication_mc.buttonMode = true;
SignApplication_mc.useHandCursor = true;

function onRollOverHandler6(event:MouseEvent):void{
	SignApplication_mc.gotoAndPlay("over");	
}
function onRollOutHandler6(event:MouseEvent):void{
	SignApplication_mc.gotoAndPlay("out");	
}
function SignApplication(event:MouseEvent):void{
	
	thisMovieClip.demo_mc.gotoAndPlay("SignApplication");	
	doesHaveAchild();
}



ConfirmApplication_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler7);
ConfirmApplication_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler7);
ConfirmApplication_mc.addEventListener(MouseEvent.CLICK, Confirmapplication);
ConfirmApplication_mc.buttonMode = true;
ConfirmApplication_mc.useHandCursor = true;

function onRollOverHandler7(event:MouseEvent):void{
	ConfirmApplication_mc.gotoAndPlay("over");	
}
function onRollOutHandler7(event:MouseEvent):void{
	ConfirmApplication_mc.gotoAndPlay("out");	
}
function Confirmapplication(event:MouseEvent):void{
	
	thisMovieClip.demo_mc.gotoAndPlay("Confirmapplication");	
	doesHaveAchild();
}



LogOut_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler8);
LogOut_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler8);
LogOut_mc.addEventListener(MouseEvent.CLICK, Logout);
LogOut_mc.buttonMode = true;
LogOut_mc.useHandCursor = true;

function onRollOverHandler8(event:MouseEvent):void{
	LogOut_mc.gotoAndPlay("over");	
}
function onRollOutHandler8(event:MouseEvent):void{
	LogOut_mc.gotoAndPlay("out");	
}
function Logout(event:MouseEvent):void{
	
	thisMovieClip.demo_mc.gotoAndPlay("Logout");	  
	doesHaveAchild();
}


Life_mc.buttonMode = true;
Life_mc.useHandCursor = true;
Life_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverLife);
Life_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutLife);
function onRollOverLife(event:MouseEvent):void{
	Life_mc.gotoAndPlay("over");	
}
function onRollOutLife(event:MouseEvent):void{
	Life_mc.gotoAndPlay("out");	
}
Life_mc.addEventListener(MouseEvent.CLICK, Life);
function Life(event:MouseEvent):void{
  WhoLoadingMovie=1;
  WhoisInside();
}


STD_mc.buttonMode = true;
STD_mc.useHandCursor = true;
STD_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverSTD);
STD_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutSTD);
function onRollOverSTD(event:MouseEvent):void{
	STD_mc.gotoAndPlay("over");	
}
function onRollOutSTD(event:MouseEvent):void{
	STD_mc.gotoAndPlay("out");	
}
STD_mc.addEventListener(MouseEvent.CLICK, STD);
function STD(event:MouseEvent):void{
  WhoLoadingMovie=2;
  WhoisInside();
}

LTD_mc.buttonMode = true;
LTD_mc.useHandCursor = true;
LTD_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverLTD);
LTD_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutLTD);
function onRollOverLTD(event:MouseEvent):void{
	LTD_mc.gotoAndPlay("over");	
}
function onRollOutLTD(event:MouseEvent):void{
	LTD_mc.gotoAndPlay("out");	
}
LTD_mc.addEventListener(MouseEvent.CLICK, LTD);
function LTD(event:MouseEvent):void{
  WhoLoadingMovie=5;
  WhoisInside();
}




Istd_mc.buttonMode = true;
Istd_mc.useHandCursor = true;
Istd_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverISTD);
Istd_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutISTD);
function onRollOverISTD(event:MouseEvent):void{
	Istd_mc.gotoAndPlay("over");	
}
function onRollOutISTD(event:MouseEvent):void{
	Istd_mc.gotoAndPlay("out");	
}
Istd_mc.addEventListener(MouseEvent.CLICK, ISTDisability);
function ISTDisability(event:MouseEvent):void{
  WhoLoadingMovie=3;
  WhoisInside();
}


Critical_mc.buttonMode = true;
Critical_mc.useHandCursor = true;
Critical_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverCritical);
Critical_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutCritical);
function onRollOverCritical(event:MouseEvent):void{
	Critical_mc.gotoAndPlay("over");	
}
function onRollOutCritical(event:MouseEvent):void{
	Critical_mc.gotoAndPlay("out");	
}
Critical_mc.addEventListener(MouseEvent.CLICK, Critical);
function Critical(event:MouseEvent):void{
  WhoLoadingMovie=6;
  WhoisInside();
}




Accident_mc.buttonMode = true;
Accident_mc.useHandCursor = true;
Accident_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverAccident);
Accident_mc.addEventListener(MouseEvent.ROLL_OUT, onRollOutAccident);
function onRollOverAccident(event:MouseEvent):void{
	Accident_mc.gotoAndPlay("over");	
}
function onRollOutAccident(event:MouseEvent):void{
	Accident_mc.gotoAndPlay("out");	
}
Accident_mc.addEventListener(MouseEvent.CLICK, Accident);
function Accident(event:MouseEvent):void{
  WhoLoadingMovie=4;
  WhoisInside();
}

Open in new window

0
 
LVL 4

Author Comment

by:eddyperu
ID: 34176443
I can't use the playmovie function 'cause each movie will contain a  LoadingVariable  number and a LoadingTimeLite number completely independent from the other movies.

Thanks
0
 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 34176465
Did you get a chance to try the *.fla file I attached?

I find it odd that you can't use unloadAndStop. The AS3 code is useful but if you could upload your fla, it would be even better.

I'll play with it and see if I can replicate your scenario.

-V
0
 
LVL 4

Author Comment

by:eddyperu
ID: 34176524
I am sending you the file
Thank you again

ps: I am really new with as3,
 Project.zip Project.zip
0
 
LVL 18

Accepted Solution

by:
Antonio Estrada earned 500 total points
ID: 34177213
Ok, so I changed a bunch of things... this is the new code:

var addPause1:addPause = new addPause();
var c:int =0;
var o:int =0;
var WhoLoadingMovie:int =0;
var LoadingVariable:Number =0;
var LoadingTimeLite:Number =0;

var thisMovieClip:MovieClip;
var thisLoader:Loader = new Loader();


WhoisInside();
function WhoisInside():void{
	thisLoader.unloadAndStop();
	 if(WhoLoadingMovie == 0){
		 thisLoader.load(new URLRequest("Movie1.swf"));
		 thisLoader.name = "MainMovie";
		 LoadingVariable = 11.90;
		 LoadingTimeLite = 640;
	 }
	 if(WhoLoadingMovie == 1)
	 {
		 thisLoader.load(new URLRequest("Movie2.swf"));
		 thisLoader.name = "LongTermDisability";
		 LoadingVariable = 1.35;
		 LoadingTimeLite = 640;		 
		 WhoLoadingMovie = 0;
	 }		
	 if(WhoLoadingMovie == 2)
	 {
		 thisLoader.load(new URLRequest("ShortTermDisability2.swf"));
		 thisLoader.name = "ShortTermDisability";
		 LoadingVariable = .95;
		 LoadingTimeLite = 640;		 
		 WhoLoadingMovie = 0;
	 }	 
	 if(WhoLoadingMovie == 3)
	 {
		 thisLoader.load(new URLRequest("IndividualShortTermDisability.swf"));
		 thisLoader.name = "IndiVidualShortTermDisability";
		 LoadingVariable = 1.35;
		 LoadingTimeLite = 640;		 
		 WhoLoadingMovie = 0;
	 }		
	 if(WhoLoadingMovie == 4)
	 {
		 thisLoader.load(new URLRequest("Accident.swf"));
		 thisLoader.name = "Accident";
		 LoadingVariable = .95;
		 LoadingTimeLite = 640;		 
		 WhoLoadingMovie = 0;
	 }	 
	 if(WhoLoadingMovie == 5)
	 {
		 thisLoader.load(new URLRequest("LongTermDisability2.swf"));
		 thisLoader.name = "LongTermDisability";
		 LoadingVariable = .95;
		 LoadingTimeLite = 640;		 
		 WhoLoadingMovie = 0;
	 }		
	 
	 if(WhoLoadingMovie == 6)
	 {
		 thisLoader.load(new URLRequest("CriticalIllness.swf"));
		 thisLoader.name = "CriticalIllness";
		 LoadingVariable = 1.15;
		 LoadingTimeLite = 640;		 
		 WhoLoadingMovie = 0;
	 }			 
    thisLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, doneLoading);	
    var info:LoaderInfo = LoaderInfo(thisLoader.contentLoaderInfo)	 
    //trace(info.loaderURL);OnlySWFDemoCopy.fla
	//trace(thisLoader.name);

}


function doneLoading(e:Event):void { 
  /*var tempMovie:MovieClip = loadDemo_mc.addChild(thisLoader) as MovieClip;
  tempMovie.addEventListener(Event.ENTER_FRAME, runOnce);*/
  loadDemo_mc.addChild(thisLoader);
  thisLoader.content.addEventListener(Event.ENTER_FRAME, runOnce);
}

function runOnce(event:Event):void {
    //trace(thisMovieClip.demo_mc.currentFrame);OnlySWFDemoCopy
	c = event.currentTarget.currentFrame;
	o = event.currentTarget.totalFrames;	
	var Result:Number = o/.21;
   // trace(Result);
	//trace("timeNumer: "+c+" LoadingVariable: "+o);
}

Open in new window


I replaced your original swf names with some I had there just to try it out. There are some other errors in the showProgress and closeEverything functions but that's beyond the scope of loading the files.

Now, trying it "as is", won't cut it since the unloadAndStop error was happening because of the Flash Player version you were compiling to. That method was added on Flash Player 10, so you need to target that.

Change it here:

File -> Publish Settings, and then

Info
-V
0
 
LVL 18

Assisted Solution

by:Antonio Estrada
Antonio Estrada earned 500 total points
ID: 34177270
By the way, if you can't target Flash Player 10 (maybe you're using Flash Professional 8), you can do this:

thisLoader.unload();
SoundMixer.stopAll();

Open in new window


Instead of this:

thisLoader.unloadAndStop();

Open in new window


-V
0
 
LVL 4

Author Closing Comment

by:eddyperu
ID: 34266872
Thanks buddy!!
0
 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 34267600
Glad to help :)

-V
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to record live broadcast.

635 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