The swf probably hangs because when you move your mouse, you trigger MOUSE_MOVE
events and the like on every single MovieClip on the screen.
You can generally optimize the Flash rendering by going a few steps higher on the MovieClip
inheritance tree and building your own graphics class from there. MovieClip
s have a lot of cool bells and whistles, like timelines, layers, and built-in mouse handling. Unfortunately, all of those take up memory and CPU time, and pretty often, you won't need all of those features. Fortunately, you can pick and choose the features you need, and get rid of a lot of the excess fat that MovieClip
s have. The MovieClip
inheritance tree is laid out so each of those features is encapsulated pretty succinctly in one parent class.
For example, with your application, you say that your MovieClip
s contain a simple shape following a simple motion path. I'm also assuming that they're not going to interact with the mouse or keyboard. We can go up MovieClip
's inheritance tree pretty far because of that. Since you're only moving a shape, and not really animating parts of it, you can replace the timeline animation with a tween (I'd recommend looking at TweenLite by Greensock). Right there, you can write your own class that subclasses Sprite
(instead of MovieClip
), and probably get a decent increase in framerate.
If you want to optimize further, you can go further up. You also probably don't need layers, since you're using a simple shape. Therefore, you can go up further than DisplayObjectContainer
. Since you don't need interactivity, InteractiveObject
can also go. So you've trimmed a lot of fat off, and now you're at DisplayObject
. Since DisplayObject
s can be difficult to work with, you might want to go down the tree one step, either to Shape
or Bitmap
, depending on how complex your shape is.
Once again, when you decide how much you need from Actionscript's built in graphics classes, you may have to build your own from there. Since you're adding custom features to your display object, you will need to create your own class that inherits from either Sprite
, Shape
, or Bitmap
, and add that functionality there.
And to answer your question about why 100 MCs is slow, keep in mind that Flash runs on a virtual machine, and that layer of abstraction is a big resource hog.