User Guide
EventDispatcher.addEventListener() 501
EventDispatcher.addEventListener()
Availability
Flash Player 6 (6.0.79.0).
Edition
Flash MX 2004 and Flash MX Professional 2004.
Usage
componentInstance.addEventListener(event, listener)
Parameters
event A string that is the name of the event.
listener A reference to a listener object or function.
Returns
Nothing.
Description
Method; registers a listener object with a component instance that is broadcasting an event.
When the event occurs, the listener object or function is notified. You can call this method
from any component instance. For example, the following code registers a listener to the
component instance
myButton:
myButton.addEventListener("click", myListener);
You must define the listener as either an object or a function before you call
addEventListener() to register the listener with the component instance. If the listener is
an object, it must have a callback function defined that is invoked when the event occurs.
Usually, that callback function has the same name as the event with which the listener is
registered. If the listener is a function, the function is invoked when the event occurs. For
more information, see “Using listeners to handle events” in Using Components.