• flickr
  • linkedin
  • twitter
  • rss
Preloader in AS2

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:

Larry's a 30-something chap interested in travel, being a dork and changing the world via less boring training.

Leave a reply