AS3 Preloader

Found a good piece of code that is just a straight forward, simple barebones preloader

addEventListener(Event.ENTER_FRAME, preloaderFunction);
function preloaderFunction(event:Event) :void {
  var bytestotal = stage.loaderInfo.bytesTotal;
  var bytesloaded = stage.loaderInfo.bytesLoaded;
  var pctLoaded:int = bytesloaded * 100 / bytestotal;
  preloader.loadingField.text = String(pctLoaded) + "%";
  if (bytesloaded >= bytestotal) {
    removeEventListener(Event.ENTER_FRAME, preloaderFunction);
    nextFrame();
  }
}

Source:
MikeTheVike at: http://www.actionscript.org/forums/showthread.php3?t=151850

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 ↑