Preloader in AS2

This was suprisingly annoying, AS2 is out of control. As usual Kirupa came through in the end. Here’s a snippet:

this.createEmptyMovieClip("container", "100"); 
my_mc = new MovieClipLoader(); 
preload = new Object(); 
my_mc.addListener(preload); 
preload.onLoadStart = function(targetMC) { 
trace("started loading "+targetMC); 
container._visible = false; 
bar._visible = true; 
border._visible = true; 
pText._visible = true; 
}; 
preload.onLoadProgress = function(targetMC, lBytes, tBytes) { 
//bar._width = (lBytes/tBytes)*100; 
pText.text = "Loading...\n"+Math.round((lBytes/tBytes)*100)+"%"; 
}; 
preload.onLoadComplete = function(targetMC) { 
container._visible = true; 
//border._visible = false; 
//bar._visible = false; 
pText._visible = false; 
trace(targetMC+" finished"); 
}; 


my_mc.loadClip("GettingStarted.swf", "container"); 

src: http://www.kirupa.com/developer/actionscript/moviecliploader2.htm

Tech Reference:

Leave a Reply

Your email address will not be published. Required fields are marked *

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑