Some two dozen event types are associated with the Event class itself and are represented by
Event class constants, some of which are shown in the following excerpt from the Event class
definition:
package flash.events
{
public class Event
{
// class constants
public static const ACTIVATE:String = "activate";
public static const ADDED:String
// remaining constants omitted for brevity
}
}
These constants provide an easy way to refer to specific event types. You should use these
constants instead of the strings they represent. If you misspell a constant name in your code,
the compiler will catch the mistake, but if you instead use strings, a typographical error may
not manifest at compile time and could lead to unexpected behavior that could be difficult to
debug. For example, when adding an event listener, use the following code:
myDisplayObject.addEventListener(MouseEvent.CLICK, clickHandler);
rather than:
myDisplayObject.addEventListener("click", clickHandler);
Default behavior information
Your code can check whether the default behavior for any given event object can be prevented
by accessing the
cancelable
indicates whether or not a default behavior can be prevented. You can prevent, or cancel, the
default behavior associated with a small number of events using the
method. For more information, see
Event flow information
The remaining Event class properties contain important information about an event object
and its relationship to the event flow, as described in the following list:
The
property contains information about the parts of the event flow in which
■
bubbles
the event object participates.
The
■
eventPhase
The
property stores a reference to the event target.
target
■
The
■
currentTarget
processing the event object.
property. The
"Cancelling default event behavior" on page
property indicates the current phase in the event flow.
property stores a reference to the display list object that is currently
= "added";
property holds a Boolean value that
cancelable
preventDefault()
356.
Event objects
353