Event Listeners - Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual

Programming actionscript 3.0
Table of Contents

Advertisement

Subclasses of the Event class
For many events, the common set of properties defined in the Event class is sufficient. Other
events, however, have unique characteristics that cannot be captured by the properties
available in the Event class. For these events, the Flash Player API defines several subclasses of
the Event class.
Each subclass provides additional properties and event types that are unique to that category
of events. For example, events related to mouse input have several unique characteristics that
cannot be captured by the properties defined in the Event class. The MouseEvent class
extends the Event class by adding ten properties that contain information such as the location
of the mouse event and whether specific keys were pressed during the mouse event.
An Event subclass also contains constants that represent the event types that are associated
with the subclass. For example, the MouseEvent class defines constants for several mouse
event types, include the
As described in the section
subclass you must override the
specific to the subclass.

Event listeners

Event listeners, which are also called event handlers, are functions that Flash Player executes in
response to specific events. Adding an event listener is a two-step process. First, you create a
function or class method for Flash Player to execute in response to the event. This is
sometimes called the listener function or the event handler function. Second, you use the
addEventListener()
any display list object that lies along the appropriate event flow.
Creating a listener function
The creation of listener functions is one area where the ActionScript 3.0 event model deviates
from the DOM event model. In the DOM event model, there is a clear distinction between
an event listener and a listener function: an event listener is an instance of a class that
implements the EventListener interface, whereas a listener function is a method of that class
named
handleEvent()
contains the listener function rather than the actual listener function.
,
click
doubleClick
"Event class utility methods" on page
and
clone()
method to register your listener function with the target of the event or
. In the DOM event model, you register the class instance that
,
, and
mouseDown
mouseUp
355, when creating an Event
methods to provide functionality
toString()
event types.

Event listeners

357

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents