Skip to main content
Known Participant
November 12, 2010
Answered

[as2] Loading multiple levels into a main level

  • November 12, 2010
  • 1 reply
  • 863 views

Hi .

I´d like to know.

How could I make a preloader with multiple levels in as2?

Should I use loadMovieNum or the MovieClipLoader class?

I want to make a main progress bar, that represents the loading

of all the levels, not a progress bar for each level.

How can I make that?

Thanks

This topic has been closed for replies.
Correct answer kglad

var swfA:Array = ["swf1.swf",...,"swfN,swf"];

var mcl:MovieClipLoader=new MovieClipLoader();

var lo:Object={};

var currentLevel:Number = 1;

loadF();

lo.onLoadProgress=function(target:MovieClip,bl:Number,bt:Number):Void{

tf.text=100*( (currentLevel-1)/swfA.length  +bl/(bt*swfA.length) )+" % Loaded";

}

lo.onLoadInit=function(target:MovieClip):Void{

currentLevel++;

if(currentLevel<=levelNum){

loadF();

} else {

//start app

}

}

function loadF():Void{

mcl.loadClip(swfA[currentLevel-1],currentLevel);

}


i changed levelNum and used swfA.length but failed to change it everywhere in the code:

var swfA:Array = ["swf1.swf",...,"swfN,swf"];

var mcl:MovieClipLoader=new MovieClipLoader();

var lo:Object={};

var currentLevel:Number = 1;

loadF();

lo.onLoadProgress=function(target:MovieClip,bl:Number,bt:Number):Void{

tf.text=100*( (currentLevel-1)/swfA.length  +bl/(bt*swfA.length) )+" % Loaded";

}

lo.onLoadInit=function(target:MovieClip):Void{

currentLevel++;

if(currentLevel<=swfA.length){

loadF();

} else {

//start app

}

}

function loadF():Void{

mcl.loadClip(swfA[currentLevel-1],currentLevel);

}

1 reply

kglad
Community Expert
Community Expert
November 12, 2010

it's easiest to use the moviecliploader class, load into your levels sequentially and assume each _level is loading the same fraction of the total load.  ie, if you're loading 20 levels, each level would contribute 1/20 of the total.

Known Participant
November 12, 2010

Could you post an example?

kglad
Community Expert
Community Expert
November 12, 2010

var swfA:Array = ["swf1.swf",...,"swfN,swf"];

var mcl:MovieClipLoader=new MovieClipLoader();

var lo:Object={};

var currentLevel:Number = 1;

loadF();

lo.onLoadProgress=function(target:MovieClip,bl:Number,bt:Number):Void{

tf.text=100*( (currentLevel-1)/swfA.length  +bl/(bt*swfA.length) )+" % Loaded";

}

lo.onLoadInit=function(target:MovieClip):Void{

currentLevel++;

if(currentLevel<=levelNum){

loadF();

} else {

//start app

}

}

function loadF():Void{

mcl.loadClip(swfA[currentLevel-1],currentLevel);

}