...

View Full Version : Swfs playing in a sequence (AS3)



amarlow
09-11-2009, 03:21 PM
Hi, I am building a movie which has more than one swf. The swfs are called movie1, movie2, etc.

I want to load these swfs into a main swf that will play them in a sequential order. Such as when movie1 is finished, movie2 begins, and when movie2 stops, movie3 begins etc. The swfs themselves have AS3 and multiple frames in them, one with a menu-like interface, so it's not just a case of importing them.

So in short, two or more swfs playing in sequential order from a main swf.

I've asked around forums and the best I've got so far is



var request:URLRequest;
var loader:Loader;
var myMovies:Array = ["loader.swf", "movie2.swf"];
var movieNum:int = 0;

function loadSWF():void
{
request = new URLRequest(myMovies[movieNum]);
loader = new Loader();
loader.load(request);
stage.addChild(loader);
stage.addEventListener(Event.ENTER_FRAME, eFrame);
}

function eFrame(e:Event):void
{
if (loader.content.currentFrame == loader.content.totalFrames)
{
stage.removeChild(loader);
stage.removeEventListener(Event.ENTER_FRAME, eFrame);
request = null;
loader = null;
movieNum++;
loadSWF();
if (movieNum >= myMovies.length())
{
movieNum = 0;
}
}
}

loadSWF();

However the (loader.content.currentFrame == loader.content.totalFrames) line throws up a 1119 error in that it is 'possibly undefined' when I have declared the variable beforehand.

I can't seem to find any resources on this. Is it actually possible? I've worked on it for weeks and everyone seems completely stumped when I ask them :(

mamata
09-24-2009, 12:49 PM
hey...
http://www.google.com

gnomeontherun
09-25-2009, 12:45 AM
Yes its very possible.

http://www.lemlinh.com/as3-video-player-tutorials-roundup/

Slipsager
12-06-2009, 10:20 PM
var request:URLRequest;
var loader:Loader= new Loader();
stage.addChild(loader);


var myMovies:Array=["ani1.swf","ani2.swf", "ani3.swf"];
var movieNum:int=0;
var mcExternal:MovieClip;

function loadSWF():void {
request=new URLRequest(myMovies[movieNum]);

loader.load(request);

// waiting for the loader to be ready
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplet);


}


function onComplet(e:Event):void {

loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,onComplet);
trace("ready to call eFrame");
stage.addEventListener(Event.ENTER_FRAME, eFrame);

}


function eFrame(e:Event):void {
mcExternal=loader.content as MovieClip;
var current:int=mcExternal.currentFrame;
var total:int=mcExternal.totalFrames;

trace(current);
trace(total);


if (current >= total ) {
trace("Load next swf ");
loader.unloadAndStop();

mcExternal=null;
movieNum++;
stage.removeEventListener(Event.ENTER_FRAME, eFrame);
request=null;
loadSWF();


if (movieNum>=myMovies.length) {
movieNum=0;
}
}

}

loadSWF();

Lear
05-12-2010, 02:06 PM
Hi everyone,

I'm new to Flash and was having a similar problem -- trying to figure out how to play a series of swf files in a master file so that one file strats playing automatically after the other is done. I tried the code above, but get the following error:

Load next swf
TypeError: Error #2007: Parameter url must be non-null.
at flash.display::Loader/_load()
at flash.display::Loader/load()
at labconmaster_fla::MainTimeline/loadSWF()
at labconmaster_fla::MainTimeline/eFrame()


What am I missing? I'm working in AS3 in Flash CS4.

Thanks

J-Dub
01-06-2011, 05:30 PM
I just used the same code and got the same error. I fixed it by adding an else to the second if statment in the last function.at the end and moving the loadSWF(); inside.

function eFrame(e:Event):void {
mcExternal=loader.content as MovieClip;
var current:int=mcExternal.currentFrame;
var total:int=mcExternal.totalFrames;

trace(current);
trace(total);


if (current >= total ) {
trace("Load next swf ");
loader.unloadAndStop();

mcExternal=null;
movieNum++;
stage.removeEventListener(Event.ENTER_FRAME, eFrame);
request=null;


if (movieNum>=myMovies.length) {
movieNum=0;
}else{
loadSWF();
}
}

}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum