i devote an entire chapter (56 pages) to game optimization in http://www.amazon.com/Flash-Game-Development-Social-Mobile/dp/1435460200/ref=sr_1_1?ie=UTF8&qid=1389454383&sr=8-1&keywords=gladstien
it's not going to be possible to paste that into this forum.
but here's an excerpt from that chapter:
Optimization Techniques
Unfortunately, I know of no completely satisfactory way to organize this information. In what follows, I discuss memory management first with sub-topics listed in alphabetical order. Then I discuss CPU/GPU management with sub-topics listed in alphabetical order.
That may seem logical but there are, at least, two problems with that organization.
- I do not believe it is the most helpful way to organize this information.
- Memory management affects CPU/GPU usage, so everything in the Memory Management section could also be listed in the CPU/GPU section.
Anyway, I am going to also list the information two other ways, from easiest to hardest to implement and from greatest to least benefit.
Both of those later listings are subjective and are dependent on developer experience and capabilities, as well as, the test situation and test environment. I very much doubt there would be a consensus on ordering of these lists. Nevertheless, I think they still are worthwhile.
Easiest to Hardest to Implement
- Do not use Filters.
- Always use reverse for-loops and avoid do-loops and avoid while-loops.
- Explicitly stop Timers to ready them for gc (garbage collection).
- Use weak event listeners and remove listeners.
- Strictly type variables whenever possible.
- Explicitly disable mouse interactivity when mouse interactivity not needed.
- Replace dispatchEvents with callback functions whenever possible.
- Stop Sounds to enable Sounds and SoundChannels to be gc'd.
- Use the most basic DisplayObject needed.
- Always use cacheAsBitmap and cacheAsBitmapMatrix with air apps (i.e., mobile devices).
- Reuse Objects whenever possible.
- Event.ENTER_FRAME loops: Use different listeners and different listener functions applied to as few DisplayObjects as possible.
- Pool Objects instead of creating and gc'ing Objects.
- Use partial blitting.
- Use stage blitting.
- Use Stage3D.
Greatest to Least Benefit
- Use stage blitting (if there is enough system memory).
- Use Stage3D.
- Use partial blitting.
- Use cacheAsBitmap and cacheAsBitmapMatrix with mobile devices.
- Explicitly disable mouse interactivity when mouse interactivity not needed.
- Do not use Filters.
- Use the most basic DisplayObject needed.
- Reuse Objects whenever possible.
- Event.ENTER_FRAME loops: Use different listeners and different listener functions applied to as few DisplayObjects as possible.
- Use reverse for-loops and avoid do-loops and while-loops.
- Pool Objects instead of creating and gc'ing Objects.
- Strictly type variables whenever possible.
- Use weak event listeners and remove listeners.
- Replace dispatchEvents with callback functions whenever possible.
- Explicitly stop Timers to ready for gc.
- Stop Sounds to enable Sounds and SoundChannels to be gc'd.