AS3 Bitmap Cached Animations
Rendering a vector for every frame of a repeated animation (like in most games) take a lot of CPU. It takes even more CPU to have lots of complex characters on screen - many the same sprite.
cacheAsBitmap in flash is good, but only if you have static objects but recreates the bitmap data of an animation every frame, making it run even slower. The best solution is to cache each frame of an animation as a bitmapData, and then switch between them each frame. This works well until you have multiple instances of the same sprite - You dont want to pre-render the bitmap data and keeping it in memory many times, so it is best to keep a library of animations, and then reference the cached frames for each instance.
Another advantage of this technique is it seems to make use of Flash’s new multi-core support. On a dual core CPU it can, if you push it, take almost 100% of resources. Trying it on a quad-core seemed only to take up two CPUs though. I guess this is both a blessing and a curse as you’re more likely to grind a users system to a halt, even if they have multiple CPUs.
Animations copyright Nathan J. - http://www.scarygirl.com/
June 19th, 2008 at 5:39 am
I’ve attempted similar things before, but simpler, and this is not a well-known technique. Your implementation is really well-done. What license is your code here under?
June 19th, 2008 at 11:35 am
We will be using the LGPL liscence for our code releases- you can do what you want with it
I have a better version of the system with more useful features. Will upload a V2 soon. cheers