The DisplayObject class supports basic functionality like the x and y position of an object, as well as more advanced properties of the object such as its transformation matrix.
DisplayObject is an abstract base class; therefore, you cannot call
DisplayObject directly. Invoking
new DisplayObject() throws an
All display objects inherit from the DisplayObject class.
The DisplayObject class itself does not include any APIs for rendering content onscreen. For that reason, if you want create a custom subclass of the DisplayObject class, you will want to extend one of its subclasses that do have APIs for rendering content onscreen, such as the Shape, Sprite, Bitmap, SimpleButton, TextField, or MovieClip class.
The DisplayObject class contains several broadcast events. Normally, the
target of any particular event is a specific DisplayObject instance. For
example, the target of an
added event is the specific
DisplayObject instance that was added to the display list. Having a single
target restricts the placement of event listeners to that target and in
some cases the target's ancestors on the display list. With broadcast
events, however, the target is not a specific DisplayObject instance, but
rather all DisplayObject instances, including those that are not on the
display list. This means that you can add a listener to any DisplayObject
instance to listen for broadcast events. In addition to the broadcast
events listed in the DisplayObject class's Events table, the DisplayObject
class also inherits two broadcast events from the EventDispatcher class:
Some properties previously used in the ActionScript 1.0 and 2.0
MovieClip, TextField, and Button classes(such as
_y, and others) have equivalents in the
ActionScript 3.0 DisplayObject class that are renamed so that they no
longer begin with the underscore(_) character.
For more information, see the "Display Programming" chapter of the ActionScript 3.0 Developer's Guide.
typeThe type of event.
useCaptureDetermines whether the listener works in the capture phase or the target and bubbling phases. If
useCaptureis set to
true, the listener processes the event only during the capture phase and not in the target or bubbling phase. If
false, the listener processes the event only during the target or bubbling phase. To listen for the event in all three phases, call
addEventListenertwice, once with
true, then again with
priorityThe priority level of the event listener. The priority is designated by a signed 32-bit integer. The higher the number, the higher the priority. All listeners with priority n are processed before listeners of priority n-1. If two or more listeners share the same priority, they are processed in the order in which they were added. The default priority is 0.
useWeakReferenceDetermines whether the reference to the listener is strong or weak. A strong reference(the default) prevents your listener from being garbage-collected. A weak reference does not.
Class-level member functions are not subject to garbage collection, so you can set
true for class-level member functions without subjecting them to garbage collection. If you set
true for a listener that is a nested inner function, the function will be garbage-collected and no longer persistent. If you create references to the inner function(save it in another variable) then it is not garbage-collected and stays persistent.
listenerspecified is not a function.
eventThe Event object that is dispatched into the event flow. If the event is being redispatched, a clone of the event is created automatically. After an event is dispatched, its
targetproperty cannot be changed, so you must create a new copy of the event for redispatching to work.
trueif the event was successfully dispatched. A value of
falseindicates failure or that
preventDefault()was called on the event.
ErrorThe event dispatch recursion limit has been reached.
xThe x coordinate to test against this object.
yThe y coordinate to test against this object.
shapeFlagWhether to check against the actual pixels of the object (
true) or the bounding box (
trueif the display object overlaps or intersects with the specified point;
typeThe type of event.
useCaptureSpecifies whether the listener was registered for the capture phase or the target and bubbling phases. If the listener was registered for both the capture phase and the target and bubbling phases, two calls to
removeEventListener()are required to remove both, one call with
true, and another call with