These tips are based on Flash CS4. They are also useful for CS3 and possibly some earlier versions.

It’s been about 3 weeks since I started programming in Flash AS3. I’ve caused the compiler an unholy amount of errors and here’s what I’ve learned.

The List

  1. FlashDevelop
  2. This editor is leagues better than the one included in Flash CS4. Autocomplete and function parameters are two of its greatest features.

  3. Preventing Memory Leaks
  4. It’s extremely important to a big project that you understand how to make the garbage collector delete objects. I highly recommend reading this link on AS3 Garbage Collection, or you may spend several hours reworking your Flash Project when you find out it has memory leaks.

  5. Event Listeners
  6. Adding Event Listeners to objects should usually be invoked with addEventListener( Event, callback, false, 0, true ). If you do not have the last parameter set to true, the garbage collector will not delete that Event Listener’s class until you manually remove it.

  7. Display List
  8. Objects most recently added to the stage with addChild() will appear on top of other objects. When you invoke addChild(displayObject), it is stored in the parent object’s display list. Flash goes through each display list, starting with the stage, and renders each object.

  9. Global Variables
  10. From an Object Oriented perspective, these are bad. However, sometimes it’s really useful to have them.

  11. Box2D Physics Engine
  12. One of the top physics engines for Flash, and for good reason. It is fast, powerful, and has numerous ports to other languages. One word of caution: you cannot use concave shapes.

  13. mathMisc.as
  14. These are just a few useful math functions I didn’t find in Flash. The naming and arguments follow the similar functions from Game Maker 7. If you’re good at trig these are very simple, but still useful. (point_direction, point_distance, lengthdir_x, lengthdir_y, degToRad, radToDeg)

  15. MonterDebugger
  16. Along with providing an nice graph of your Flash’s memory usage and FPS, MonsterDebugger will allow you to trace around your classes and see everything going on under the hood. This helps when you start getting runtime errors, but note that it takes a while to figure out the structure of this debugger to get useful data from it.

  17. Setting the Class of a .swf
  18. You can specify a default ActionScript class that a .swf file should load on runtime. You can reach this under the Document Properties panel, where you type in the name of the file under Class (without the .as).

  19. Setting the Path to your AS3 files
  20. Flash will throw an error if it can’t find your AS3 files. You can tell Flash where to find these under File -> Publish Settings -> ActionScript 3.0 -> Sourcepaths.

Hope this helps you out a bit.

Related posts:

  1. Dynamic Movieclip Animation Speed in AS3