
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Listener Events
|
225
If the code were attached to the ball movie clip itself, you could instead write:
delete this.onEnterFrame;
For a list of event handlers offered by a specific class or object, see the appropriate
entry in the Language Reference. In particular, be sure to study the Button and
MovieClip classes, which define the majority of user-interaction events. For exam-
ple, to cause a submitForm( ) function to execute when a Submit button is pressed,
we use:
submit_btn.onRelease = submitForm;
function submitForm ( ) {
// Validate data and send it to the server...
}
where submit_btn is the button object, the onRelease event is invoked when the but-
ton is pressed and then released, and submitForm( ) is a custom function that sends
the form data to the server. For a complete form-submission example, see
Chapter 17.
Event handlers are convenient, but they also suffer from a shortcoming: only one call-
back function can be registered (assigned) to an event handler at a time. That is, only
one action can be performed for each event when using event handler properties.
We’ll learn how to overcome this limitation in the next section using listener events.
Listener Events
Conceptually, listener events are similar to event handler properties. Like event han-
dler properties, listener events ...