More performance tuning in Actionscript 3
I noticed a link yesterday over at RozenGain’s Blog about performance tuning, and I might have a couple things to add to the list as well. Go look at his blog first, as they’re not as obscure as mine :). He’s also got links to other performance tuning posts that are extremely helpful as well. If you’re working with bitmaps a lot, check out one of my previous blog posts about bitmap performance tuning. The methods below are for squeezing every last drop of cpu performance out of the runtime (sometimes at the cost of memory albeit very little memory), and is really only designed if you’re trying to squeeze 1 millisecond off your Event.ENTER_FRAME scripts. Here goes:
Create constants for commonly used objects, such as new Point(0,0), new Rectangle(0,0,320,240), etc. This reduces overhead of creating new objects.
Often when dealing with bitmaps, we’ll use new Point(0,0) quite often, or filter rectangles. If these stay constant, store them as a variable and re-use them as often as possible. Each of the following examples use 100,000 iterations.

