Flash and ActionScript 3 Best Practices to Improve Performance

Aug 19th, 2009 by Stuntman

This article will teach you tricks and best practices for creating a Flash Website. Learn simple things you can do to make your website load faster and perform better for your users.

Flash websites by nature are very heavy.  They tend to load slower than normal HTML sites and perform a little slower as well.  This is not all Flash's fault.  There are a lot of tricks you can do when developing your Flash site to make sure your users get the best experience.

  • Optimize images before you import them into your Flash file.  (reduces file size)
  • When exporting your Flash change the JPEG quality to 60, under publish settings.  You may want to bump some images even lower than 60.  You will perform this by double clicking the jpeg in the library.  (reduces file size)
  • Use switch statements instead of a group of if/else statements. (better for performance)
  • If you need to loop through an array, declare the array length as an int before the for loop. (better for performance)
  • Remove all listeners.  You do not want your Flash experience to still be listening for events after they are completed. (better for performance)
  • Remove/Unload unneeded assets from the stage, when done with them.  Simple spinney animations in the background will take up valuable CPU resources. (better for performance)
  • Use int instead of number when needed. A number var allocates more memory than an int. (example: use int for 5.  user Number for 5.6) (better for performance)
  • Preload your project and all external assets. (better user experience)
  • DON'T WRITE CODE INSIDE THE FLA (best practices)
  • Make sure you stop and clear timers/intervals when not in use. (better for performance)
  • Try to use vector art drawn in Flash, so your graphics will be a lot crisper. (better for performance and reduces file size)
  • Reuse common functionality. (example: have one function for your preloading, one for your loading xml, etc) (best practice)
  • Make sure you convert all your tweened objects to a MovieClip!  If you have any symbol in your library called Tween 1, this means you did not convert that item to a MovieClip first! (best practice)
Stuntman

Written by Stuntman

Rate this Article:

Rating: 5.0/5 (5 votes cast)

Image via Wikipedia

Add new comment

* You must be logged in order to leave comments, please Sign in or join us.

Comments

Filipe Cunha, over a year ago
Report comment

for loops use uint instead int. you can add to list… use getChildAt instead getChildByName :)

alshayal, over a year ago
Report comment

Thank You ... Thank You ... Thank You ...
This boosted my work… This is woOOOow
Thank You ... Thank You ... Thank You ...