Posted By

chrisaiv on 02/08/08


Tagged

as3


Versions (?)

Who likes this?

14 people have marked this snippet as a favorite

outbox
visuallyspun
jmontanino
SmpleJohn
THEPWN3R
enajenkins
aesthetics
loric
ssolen
djmaddy
donaldleegraham
tspitzr
adrianparr
dug


AS3: Custom Preloader


 / Published in: ActionScript 3
 

Create a 100 frame MovieClip animation in companion with this code to create a preloader. Place the rest of your Flash application on the following Scene or Frame

  1. /***************************
  2. Event Handler
  3. ***************************/
  4. addEventListener(Event.ENTER_FRAME, loading);
  5.  
  6. /***************************
  7. Function
  8. ***************************/
  9. function loading(e:Event)
  10. {
  11. var bytestotal = stage.loaderInfo.bytesTotal;
  12. var bytesloaded = stage.loaderInfo.bytesLoaded;
  13. var percent = Math.round(bytesloaded * 100/bytestotal);
  14.  
  15. mc_with_100_frame_animation.gotoAndPlay(percent);
  16.  
  17. if (bytesloaded >= bytestotal)
  18. {
  19. gotoAndStop(2);
  20. removeEventListener(Event.ENTER_FRAME, loading);
  21. removeChild(custom_animation);
  22. }
  23. }
  24. stop();

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Slugtaco on April 14, 2009

Is the "customanimation" referring to the "mcwith100frame_animation"?

I received this error when trying it.

1120: Access of undefined property custom_animation.

Posted By: chrisaiv on April 24, 2009

Your custom animation is a 100 Frame MovieClip with, in this case, an instance name of "mcwith100frameanmiation"

Posted By: melolonta on August 28, 2010

hello, I'm new at as3 and noob with flash also, i'm having this trouble..

function does not have a body (line 9 here 18 in flash)

i love the 100 frames preloaders, so this is perfect for me thx!!!!!!

thanyou

You need to login to post a comment.