Have you ever wondered why you have to use a MovieClip instead of a Button symbol type when you want to access the child elements? Here's the explanation...
MovieClip
The MovieClip class in ActionScript has the following inheritance tree:
MovieClip - Sprite - DisplayObjectContainer - InteractiveObject - DisplayObject - EventDispatcher - Object
The ability to interact with child elements of the movie clip come from the DisplayObjectContainer class, which has the numChildren property and the addChild, addChildAt, contains, getChildAt, getChildByName, getChildIndex, removeChild, removeChildAt, setChildIndex, swapChildren, and swapChildrenAt methods.
SimpleButton
The SimpleButton class in ActionScript has the following inheritance tree:
SimpleButton - InteractiveObject - DisplayObject - EventDispatcher - Object
None of the classes in this hierarchy contain methods to deal with child elements.
Subscribe to:
Post Comments (Atom)
very useful, thanks mate
ReplyDelete