Mouse Object | Flash 5; enhanced in Flash 6 to add listener events |
mouse events and control over mouse pointer visibility |
Registers an object to receive onMouseDown( ), onMouseMove( ), and onMouseUp( ) events.
Hides the mouse pointer.
Cancels event notices for the specified listener.
Enables the mouse pointer.
Occurs when the primary mouse button is depressed.
Occurs when the mouse pointer moves.
Occurs when the primary mouse button is released.
The Mouse object provides feedback from mouse events and control over the visibility of the mouse pointer. Using the Mouse events, we can create mouse-driven interfaces that respond to mouseclicks and mouse movement. However, for menu- and button-based applications, the mouse-related Button events (onPress( ), onRelease( ), onRollOver( ), etc.) provide easier access to mouse actions. The mouse event handlers, such as onMouseDown( ), are useful when you want to trap mouseclicks not associated with a particular button. For example, you can use them to trap a mouseclick anywhere on-screen, which might be useful to advance a slideshow.
We use Mouse.hide( ) to conceal the system mouse pointer, usually in order to replace it with a customized mouse pointer, as shown in the Example under Mouse.hide( ). It may also be desirable to hide the mouse pointer in fullscreen, keyboard-controlled movies or for touch-screen kiosks.
Note that the Mouse object does not tell us the location of the mouse pointer. Use _root._xmouse and _root._ymouse to determine the mouse pointer's location relative to the main Stage. Use the _xmouse and _ymouse properties of a movie clip object to determine the mouse pointer's location relative to the clip.
The onMouseDown( ), onMouseMove( ) and onMouseUp( ) listener events were added to the Mouse object in Flash 6. They are generally preferred over the analogous Flash 5-style clip events mouseDown, mouseMove, and mouseUp, which are used within an onClipEvent block to detect mouse input. However, in Flash 6, the updateAfterEvent( ) function, which refreshes the screen between frames, can be used only with MovieClip mouse or key events or with setInterval( ). Hence, when a screen refresh is required between frames, the MovieClip.onMouseDown( ), MovieClip.onMouseMove( ), and MovieClip.onMouseUp( ) handlers must be used. See those entries in this Language Reference for details. Future versions of the Player will likely include support for updateAfterEvent( ) from Mouse listener events.
Button.onPress( ), Button.onRelease( ), MovieClip.onMouseDown( ), MovieClip.onMouseMove( ), MovieClip.onMouseUp( ), MovieClip._xmouse, MovieClip._ymouse, updateAfterEvent( )