home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

Book HomeActionScript: The Definitive GuideSearch this book

10.5. Event Handler Syntax

The names of events (and their corresponding event handlers) are predetermined by ActionScript. Button event handlers are defined using on (eventName), and movie clip event handlers are defined using onClipEvent (eventName), where eventName is the name of the event to be handled.

Hence, all button event handlers (except keyPress, which also requires a key parameter) take the form:

on (eventName) {
  statements
}

A single button handler can respond to multiple events, separated by commas. For example:

on (rollover, rollOut) {
  // Invoke a custom function in response to both the rollOver and rollOut events
  playRandomSound( );
}

All movie clip event handlers take the form:

onClipEvent (eventName) {
  statements
}

Unlike button handlers, clip handlers can respond only to a single event.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.











??????????????@Mail.ru