useful tips and resources

Simple Preloader in ActionScript 3

August 20th, 2008 · No Comments

It is just a few number of lines for making a simple preloader. You may download this file as an example. Below codes are located in actions layer of preloader scene.

Actionscript:
  1. stop();
  2. var loaded:Number;
  3. var percent:Number;
  4. fm_bar.addEventListener( Event.ENTER_FRAME, load_progress );
  5.  
  6. function load_progress(e:Event):void
  7. {
  8. loaded = stage.loaderInfo.bytesLoaded / stage.loaderInfo.bytesTotal;
  9. percent = Math.round(loaded * 100);
  10.  
  11. fm_bar.scaleX = loaded;
  12. loader_info.text = “Loading… “ + percent + “%”;
  13.  
  14. if( percent == 100 )
  15. {
  16. fm_bar.removeEventListener( Event.ENTER_FRAME, load_progress );
  17. play();
  18. }
  19. }

Tags: ActionScript 3 · Flash

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment