User Guide

How ActionScript 3.0 event handling differs from earlier versions 349
Not all default behaviors can be prevented. For example, Flash Player generates a MouseEvent
object when a user double-clicks a word in a TextField object. The default behavior, which
cannot be prevented, is that the word under the cursor is highlighted.
Many types of event objects do not have associated default behaviors. For example, Flash
Player dispatches a connect event object when a network connection is established, but there
is no default behavior associated with it. The API documentation for the Event class and its
subclasses lists each type of event and describes any associated default behavior, and whether
that behavior can be prevented.
It is important to understand that default behaviors are associated only with event objects
dispatched by Flash Player, and do not exist for event objects dispatched programmatically
through ActionScript. For example, you can use the methods of the EventDispatcher class to
dispatch an event object of type
textInput, but that event object will not have a default
behavior associated with it. In other words, Flash Player will not display a character in a
TextField object as a result of a
textInput event that you dispatched programmatically.
What’s new for event listeners in ActionScript 3.0
For developers with experience using the ActionScript 2.0 addListener() method, it may be
helpful to point out the differences between the ActionScript 2.0 event listener model and the
ActionScript 3.0 event model. The following list describes a few major differences between
the two event models:
To add event listeners in ActionScript 2.0, you use addListener() in some cases and
addEventListener() in others, whereas in ActionScript 3.0, you use
addEventListener() in all situations.
There is no event flow in ActionScript 2.0, which means that the addListener() method
can be called only on the object that broadcasts the event, whereas in ActionScript 3.0, the
addEventListener() method can be called on any object that is part of the event flow.
In ActionScript 2.0, event listeners can be either functions, methods, or objects, whereas
in ActionScript 3.0, only functions or methods can be event listeners.