Search code examples
actionscript-3performancemovieclip

Directly manage movieclip drawing. AS3


So, I'm wondering if it's possible to stop all animation, do computations such as "moving a bunch of enemies movieclips, moving some bullets, etc.", then starting the animation again so that all of the drawing would occur at once.

My application would be in the game loop of my game. The problem I'm having is that I have around 50 enemies on screen, all of which are moving very fast, and I walk through the array and move each MovieClip. There's some lag and I'd like to get rid of it in any way I can.

If I understand AS3 correctly, it would try to draw to the screen after each change of the X and Y value of each MovieClip. By stopping animation, setting these values, then starting it up again, I think I'd increase performance by quite a bit.


Solution

  • Flash renders each frame once. You can move stuff around all you want "between" frames. So, the way you are moving your enemies now is the proper way.

    Using blitting is sort of the nuclear option, you gain a lot performance wise but you'll also loose many of the benefits flash gives such as rotation/scaling and the mouse/interactivity bit.

    It's hard to give any other pointers without seeing the game, but generally, try to avoid transparency over large areas, masking can be expensive and filters can be heavy to render.