I was reading on SO about native flash rendering vs building a custom BitmapData frame buffer and some of the answers were a bit conflicting, so I was wondering:

  1. Is it generally best practice to go the custom Bitmap buffer route or is it best to leave rendering to the flash engine?
  2. If you're using vector animations (MovieClips) as opposed to sprites, does that change the answer to the above?
  3. If so is it best practice to use sprite based animations?

(I'm targeting Flash 10 if that makes any difference)


3 Answers 3


1. There is no general best practice.

If you got a lot of (complex shaped) elements, particles etc. in your game, the bitmap buffer approach is going to be much faster. The bitmap buffer will also scale better with increasing complexity of your sprites. The vector renderer will become slower with more complex shapes or tween (shape tween) animations, it has some other benefits though:

  • You can freely scale your assets or even zoom into the scene without loss of quality.
  • Rotation or other transformations like skewing will be much easier to perform on vector graphics

So in conclusion, it boils down to what kind of game you're building.

2. Using MovieClips instead of bitmap sprite-sheets

I guess you meant "bitmap sprite-sheets" and not the AS3 Sprite class?

This doesn't make a difference, really. You can always turn your MovieClip based animations into animated bitmaps. Either manually, by exporting the movie to frames and turn them into a sprite-sheet, or dynamically, by rendering a sprite sheet from your MovieClip at runtime. Here's how I would do this:

  1. Create an instance of the MovieClip and stop() it.
  2. Create a new BitmapData object with the same width and height as the Movieclip.
  3. Use the draw() method, to render the MovieClip to the BitmapData.
  4. Store the BitmapData object in an Array or Vector.
  5. Go to the next frame of your MovieClip and repeat Steps 2 - 4, do this until you reached the last frame of your MovieClip. It's also a good idea to update two variables with the max width and max height of your MovieClip frames (since these can change from frame to frame).
  6. Now you can combine all the stored BitmapData Objects into a Sprite-Sheet (use BitmapData.copyPixels())

3. Sprite-based animations

As mentioned in the answer to your first question, there's no definite answer to that. If you need to perform a lot of transformations with your objects, eg. scaling and rotating you're probably better off by using the flash native renderer. If you got pre-defined animations that can be baked to sprite-sheets (manually or dynamically), and if you need to display hundreds of sprites at the same time, then go for a bitmap-rendering engine.

  • \$\begingroup\$ When (if?) Flash starts using hardware acceleration for its rendering, a copyPixel renderer will probably be slower than the native renderer. \$\endgroup\$ Commented Aug 12, 2010 at 10:30

I would say that if you're building a raster based game using sprites, go with building a custom rendering solution using BitmapData. If you're building a vector based game, go with using the built in animation mechanisms using MovieClips.

If you go with building a custom rendering solution, you pretty much disassociate yourself from Flash using ActionScript alone to accomplish what you need. The flixel engine uses this method and it's quite nice. I prefer writing my own engine from scratch though, but you get the idea.

Going with the built in Flash animation mechanisms works best for vector based games because you can easily create your library assets as MovieClips that you can then instantiate in ActionScript on demand. You use the timeline provided the movie clips to handle animation and move the location of the sprite accordingly. All the BattleOn! games like Adventure Quest Worlds use this method. It looks nice also.

I'm assuming your last question is referring to using the Sprite class instead of the MovieClip class for vector animations. A Sprite is a MovieClip without a timeline, so you would lose the convenience of having the animations managed for you.


Even though it is a commonly held belief that blitting is faster, I have not seen any benchmarks proving this. Some developers just prefer blitting because it allows them to treat Flash as more of a generic virtual machine, and control rendering themselves. However, if you like the built-in display list (which I do), Flash can happily move, scale, rotate and apply nice effects to hundreds of on-screen DisplayObjects (e.g. MovieClips, Sprites, Bitmaps) at high frame rates, so long as they are quite small in dimensions, e.g. less than 200x200 pixels each. You can use MovieClips without using vectors. Most games will use bitmap assets whichever system they use. But it is sometimes useful to layout and animate bitmap assets on the timeline, especially if you are working with a Flash-specialist designer rather than a pixel artist. By setting the stage quality to LOW you will get much better performance at the expense of uglier transforms. Flash will not render any objects that are off screen, so they do not slow you down.

Where Flash can get slow is moving and transforming very large bitmaps - for example if you have a very large scrolling level, or lots of parallax layers. A hybrid approach of using MovieClips for your game objects while blitting the background from an offscreen buffer may be faster, and will allow you to have infinitely large levels, while still allowing the ease-of-use of standard Sprites and MovieClips.

  • \$\begingroup\$ Complex vector shapes can also have a significant impact on performance. If you got animated MovieClips with lots of gradients, and if you don't pay attention to the level of detail of your vector-shapes, then it will draw much slower than a bitmap. \$\endgroup\$
    – bummzack
    Commented Jul 22, 2010 at 15:42
  • \$\begingroup\$ You can use MovieClips without using vectors. Most games will use bitmap assets whichever system they use. But it is sometimes useful to layout and animate bitmap assets on the timeline, especially if you are working with a Flash-specialist designer rather than a pixel artist. \$\endgroup\$
    – Iain
    Commented Jul 22, 2010 at 18:58
  • \$\begingroup\$ Yeah for flash games I recomend not using gradients for anything that is going to be vector and rendered by flash each frame, other than a few things on the HUD and the player sprite. Gradients eat performance fast. \$\endgroup\$ Commented Sep 1, 2010 at 5:11
  • \$\begingroup\$ Some rendering and update benchmarks: 8bitrocket.com/2007/12/23/… \$\endgroup\$
    – Max Dohme
    Commented Aug 2, 2011 at 17:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .