# on

#### Availability

Flash 2. Not all events are supported in Flash 2.

#### Usage

    on(mouseEvent) {
    	statement(s);
    }

#### Parameters

`statement(s)` The instructions to execute when the `mouseEvent` takes place.

A `mouseEvent` is a trigger called an "event." When the event takes place, the statements following it within curly brackets execute. Any of the following values can be specified for the `mouseEvent` parameter:

- `press` The mouse button is pressed while the pointer is over the button.
- `release` The mouse button is released while the pointer is over the button.
- `releaseOutside` The mouse button is released while the pointer is outside the button after the button is pressed while the pointer is inside the button.
- `rollOut` The pointer rolls outside of the button area.
- `rollOver` The mouse pointer rolls over the button.
- `dragOut` While the pointer is over the button, the mouse button is pressed and then rolls outside the button area.
- `dragOver` While the pointer is over the button, the mouse button has been pressed then rolled outside the button and then rolled back over the button.
- `keyPress (`"`key`"`)` The specified key is pressed. The `key` portion of the parameter is specified using a key codes listed in Appendix B, "Keyboard Keys and Key Code Values" of Using Flash or any of the key constants listed in the Property summary for the Key object. .

#### Description

Event handler; specifies the mouse event or keypress that triggers an action.

#### Example

In the following script, the `startDrag()` action executes when the mouse is pressed and the conditional script is executed when the mouse is released and the object is dropped.

    on(press) {
    	startDrag("rabbit");
    }
    on(release) {
    	trace(_root.rabbit._y);
    	trace(_root.rabbit._x);
    	stopDrag();
    }

#### See also

`onClipEvent`