Game Development Reference
In-Depth Information
Object
The class Object is a root class for every object that you define in the AS3 world. If
you were to define your own object with no parent class, AS3 assumes that the class
is Object's subclass. Object enables us to create new objects using the new operator.
For example, in the following code snippet, an instance of Sprite object is created and
assigned to the variable
s
:
var s:Sprite = new Sprite();
EventDispatcher
This class mainly adds the event handling capabilities to all the classes underneath it.
This is done by implementing the
IEventDispatcher
interface. Thereby your own
subclasses of a Sprite allow you to add and remove event handlers, as you will see
later in this chapter.
DisplayObject and DisplayObjectContainer
DisplayObject
provides the functionality whereby an instance of any of its subclass
may be part of the display list. A display list is an ordered set of objects within an
instance of a
DisplayObjectContainer
. The display objects contained within a
display object container are termed as children. Thus, from the previous hierarchy,
you can see that a sprite is both a
DisplayObject
and a
DisplayObjectContainer
,
which means that sprite objects may contain other sprite objects forming a tree
of object, which is ordered. As you will see in the detailed section on sprite,
programmatically, you may manipulate this tree of objects and see how Flash
makes it all so very intuitive.
InteractiveObject
InteractiveObject
encapsulates objects that the user interacts with, such as
TextField
and
SimpleButton
. Also, notice that because they do not inherit from
DisplayObjectContainer
, the subclasses of
InteractiveObjects
cannot contain
other objects as children; they may only be used as the leaf objects in the display
object tree.