The new event model is one of the biggest changes ActionScript 3.0
introduces. Gone are the event handlers of prior versions, such as
onRelease or the more antiquated
on(release) handler applied directly to
symbol instances. The new model makes use exclusively of event
listeners. In simple terms, event listeners are established to
monitor for the occurrence of a particular event, and then execute a
function when that event is received. Since listeners are required for all
event processing, this chapter both explains and uses them
Even if you have experience with event listeners from prior versions of ActionScript (perhaps from use with components or objects for capturing key events), the event flow is quite different in ActionScript 3.0. Events can cascade down through the display list and bubble back up to the root of the file, allowing for advanced event handling. In line with the focus of this quick answer guide, this chapter covers the basic essentials of event processing, but provides an adequate overview to get you started.
You want to understand the basic operation of an event listener.
Create an event listener and accompanying function to execute when a desired event is received.
The first part of reacting to an event is to create an event
listener. You do this by using the
addEventListener() method, attaching the listener to the object that will be ...