The User-Input Movie Clip Events

The remainder of the movie clip events relate to user interaction. When any of the user-input clip events occurs, all clips on stage (no matter how deeply nested in other clips) receive the event. Hence, multiple clips may react to a single mouseclick, mouse movement, or keystroke.

To execute code based on the proximity of the mouse to a particular clip, an event handler should check the location of the mouse pointer relative to the clip. The built-in hitTest( ) function provides an easy way to check whether a mouseclick occurred within a certain region, as shown later in Example 10.9.

mouseDown

Like the press button event, the mouseDown clip event detects the downstroke of a mouseclick. The mouseDown event occurs each time the primary mouse button is depressed while the mouse pointer is over any part of the Stage.

Unlike the button press event, mouseDown is not tied to the hit area of a button. In combination with the mouseUp and mouseMove events and the Mouse.hide( ) method, the mouseDown event can be used to implement a custom mouse pointer, as we’ll see later in Example 10.8.

mouseUp

The mouseUp event is the counterpart to mouseDown. It occurs each time the primary mouse button is released while the mouse pointer is over any part of the Stage. As with mouseDown, a clip with a mouseUp handler must be present on stage at the time the mouse button is released in order for the event to have any consequence. The mouseUp, mouseDown, and mouseMove

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.