ActionScript for Flash MX: The Definitive Guide, Second Edition

ActionScript for Flash MX: The Definitive Guide, 2nd EditionBy Colin Moock
Chapter 18.  ActionScript Language Reference
Button.onPress( ) Event Handler Flash 6; on (press) supported since Flash 2

occurs when the mouse button is clicked while the pointer is over a Flash button

theButton.onPress() on (press) { statements }

Description

The onPress( ) event handler executes when the primary mouse button is depressed while the mouse pointer is in the button's hit area. Other mouse buttons (right, middle, scroll, etc.) are not detectable. Note that a "mouseclick" is a two-step process: the mouse button is depressed (press) and then released (release). Button press events are appropriate for radio buttons or weapons firing in a game, but use release events to allow the user to change his mind before releasing the mouse.

Example

cancel_btn.onPress = function () { // Handle event... trace("press detected"); };

See Also

Button.onRelease( ), MovieClip.onPress( ); Chapter 10

    Категории