Button.onRelease( ) Event Handler | Flash 6; on (release) supported since Flash 2 |
occurs when the mouse is pressed and then released while the pointer is over a Flash button |
The onRelease( ) event handler is executed when the following sequence is detected:
The mouse pointer is in the hit area of theButton.
The primary mouse button is pressed while the mouse pointer is still in the hit area of theButton (at which point an onPress( ) event occurs).
The primary mouse button is released while the mouse pointer is still in the hit area of theButton (at which point an onRelease( ) event occurs).
By using the release event instead of the press event, you give users a chance to move the pointer off of a button even after the mouse has been pressed, thus allowing them to retract their action. The onRelease( ) handler is the most common button handler in Flash. It is used to respond to the classic button click. Note that the trackAsMenu property can alter the behavior of onRelease( ), as described under Button.trackAsMenu.
The following code shows two onRelease( ) handlers. When ok_btn is clicked, the playhead of the button's parent movie clip is sent to the frame labeled begin. When cancel_btn is clicked, the playhead is sent to the frame labeled quit.
ok_btn.onRelease = function () { this._parent.gotoAndStop("begin"); } cancel_btn.onRelease = function () { this._parent.gotoAndStop("quit"); }
Button.onPress( ), Button.trackAsMenu, MovieClip.onRelease( ); Chapter 10