Skip to main content
sandys1348
Inspiring
December 1, 2017
Question

Unload a movie when the next movie loads

  • December 1, 2017
  • 3 replies
  • 514 views

I have a main swf (2017XmasParty.swf) that I've placed the following code in frame 1.  That is all I have in my main swf timeline.

var swf1:MovieClip;

var loader1:Loader = new Loader();

var defaultSWF1:URLRequest = new URLRequest("Board.swf");

loader1.load(defaultSWF1);

addChild(loader1);

In Board.swf I've placed the same code on the Actions layer, frame 1400 which is the last frame of my timeline.  Of course I changed the swf file name to my next swf that I want to load and play after Board.swf.  This works great with the exception that the previous movie is lopping and plays simultaneously with the next swf.

I am fairly new to animate and actionscript and I've been searching for a solution but everything I read is to click on something to control the actions.  I have 11 swf files that I want to play one after the other and loop.  Each file has the above script to load the next with the last one reloading the first.

I need to know how to make them unload after they play and the next one loads.  I'm under a deadline and would greatly appreciate some advice!

Thank you!

This topic has been closed for replies.

3 replies

sandys1348
Inspiring
December 2, 2017

I inserted my main movie into powerpoint and when I play the show it plays the first swf but the second ends after a few seconds and advances to the next movie.  Why does it not play the entire movie before advancing to the next one?

kglad
Community Expert
Community Expert
December 2, 2017

i don't use powerpoint so i can't answer that.

sandys1348
Inspiring
December 1, 2017

You are my hero!!!!!!!  That worked and I'm going to make my 5:00 deadline!  Thank you for your quick reply!!!!! 

kglad
Community Expert
Community Expert
December 1, 2017

you're welcome.

(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)

sandys1348
Inspiring
December 1, 2017

I copied the swf files to my local hardrive (main and every swf it loads) but when I play it from my local harddrive it doesn't play the entire movie. Any ideas?

kglad
Community Expert
Community Expert
December 1, 2017

in the last frame of Board, put:

dispatchEvent(new Event('endE'));

in your xmasParty, use:

var swfA=["Board.swf","nextswf.swf",etc];

var index:int=0;

var loader1:Loader = new Loader();

addChild(loader1);

loader1.contentLoaderInfo.addEventListener(Event.COMPLETE,completeF);

nextF(null);

function completeF(e:Event):void{

MovieClip(loader1.content).addEventListener("endE",nextF);

}

function nextF(e:Event):void{

if(index<swfA.length){

loader1.load(new URLRequest(swfA[index]));

index++;

}

}