New version here.

I’ve managed to once more squeeze better performance out of the engine. I’ve also retooled the debris placement mechanic, so it should be alot faster, more fluid and feel like ‘painting’ more than meticulous insertions.

The optimizations will no doubt continue, as I can’t seem to stop puttering with the thing, but it’s at a point where it performs pretty well all things considered.

This has been a wonderful learning experience and has illuminated a lot of tricks for optimizing AS3. I’ll share my specific thoughts in detail about this in a future post, but for now, I offer bullet pointed goodness:

  • ‘cacheAsBitmap = true’ is your friend for speeding rendering on largely static objects. (this is responsible for the most recent performance increase) A caveat to be aware of is that this property can SLOW DOWN render performance if the object in question is rotated or resized frequently.
  • onMouseMove is an evil, evil event in a highly interactive, performance sensitive app, as it can, in effect, clog the event queue and delay the onEnterFrame event from firing. It’s best to process mouse movement events within the onEnterFrame event, this keeps your main loop running smoothly.
  • Cloning multiple instances of a Bitmap by creating a master embedded copy (say as a static member of a Zombie class called ‘masterIcon’ for example) and creating new instances using the bitmapData of that static object as an argument to the Bitmap constructor saves hugely on memory allocation, and anecdotally is faster to render. for example:

‘this._zombieIcon = new Bitmap(masterIcon.bitmapData);’

  • The mechanics of writing a preloader that is NOT just a separate SWF loading in your desired SWF is a pain in the booty. In effect it is simple to accomplish once you know the super secret method, but that method is not easy to discover, as it does not seem to be represented in the official documentation. (I’ll detail said method in the next post….how’s that for a cliff hanger?!)
  • alpha values not equal to 1.0 or 0.0 are not your friend if you have many small objects in the display list with said values.
  • I can’t wait for flex builder 3 to be finished, the profiling tool that half functions in the beta version has been INVALUABLE in hunting down bottlenecks for optimization. If you don’t KNOW where your bottlenecks truly are, trying to optimize based on educated guessing is an exercise in frustration to say the least.

That wraps it up for the moment, now Go Play!

-Joe out.

Be Sociable, Share!


  1. 6 September 5:47 am

    Thanks for visiting my blog today. I Appreciate that! I must say I am impressed with the theme as well as the domain name “head meat”

    Don’t forget to visit me today for the results I will stumble you as well this afternoon.

  2. […] higher res sprites, that I had previously down res-ed in my quest for performance, turned out I was optimizing the wrong bottleneck. So that mistake has been […]

Add A Comment