Guest User

Quick bad preloader guide

a guest
Jan 31st, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import flash.events.Event;
  2.  
  3. stop(); //stop the flash at the first frame
  4. this.addEventListener (Event.ENTER_FRAME, loading);
  5.  
  6. function loading (e:Event){
  7.     //important stuff
  8.     var total:Number = this.stage.loaderInfo.bytesTotal;
  9.     var loaded:Number = this.stage.loaderInfo.bytesLoaded;
  10.  
  11.     //showing progress
  12.     var loadper = Math.round((loaded/total)*100);
  13.     txtLoad.text = loadper + "%"; //REMOVE THIS LINE IF YOU DON'T HAVE A PROGRESS TEXTBOX
  14.    
  15.     //check if flash is done loading
  16.     if(total <= loaded){
  17.         this.removeEventListener(Event.ENTER_FRAME, loading);
  18.         //Start flash in frame two
  19.         gotoAndStop(2);
  20.     }
  21. }
  22.  
  23. /*  REMEMBER TO CHANGE LOAD PRIORITIES
  24. *   do this:
  25. *   File > Actionscript settings
  26. *   Set "export classes in frame" to 2
  27. *   then in the library; Right click big assets used in frame 2 i.e. flv files, music etc.
  28. *   go to properties > Actionscript
  29. *   Check Export for actionscript and Export in frame 2
  30. *   NOTE, if you use a sound in the preloader, do not export that to frame 2
  31. *   Also a quick way to test your preloader (if you're using CS6) press ctrl enter twice to simulate download, remember to change the
  32. *   download speed
  33. *   This can be done in View > Download settings
  34. *   Good luck
  35. */
Advertisement
Add Comment
Please, Sign In to add comment