there's a large ammount of display objects in flash.display
package. It's not clear for me in what situation I should use Shape
, Sprite
or MovieClip
. What is the pro and contras in using each of them?
Thank you in advance!!
there's a large ammount of display objects in flash.display
package. It's not clear for me in what situation I should use Shape
, Sprite
or MovieClip
. What is the pro and contras in using each of them?
Thank you in advance!!
In short, stick to Sprite in most cases, unless you need to integrate with MovieClips from Flash Authoring. Shape is handy to quickly draw into and it's 'lighter' than Sprite, but not very flexible since you can't nest other elements to it.
You should always use the lightest component depending on what you need:
Shape
is the one with the least possibilities. Use it when you only want a DisplayObject
with graphics
, and no mouse interaction.Sprite
is the parent class of quite everything you need. Since it is a DisplayObjectContainer
, you can use it as a basic container for other components. You can also catch mouse events on this one.MovieClip
is a Sprite
with the ability to use frames. Only use it for frame-by-frame animation (Flash style).