Name
Mouse.hide( ) Method — make the mouse pointer disappear
Availability
Flash 5
Synopsis
Mouse.hide( )
Description
The hide( )
method causes the normal mouse
pointer (usually an arrow) to disappear when the mouse is over any
part of the Player. The normal system pointer reappears when the
mouse passes outside the Flash Player’s active stage area.
Usage
Note that in Flash 5, even after Mouse.hide( )
has been invoked, the normal system text I-beam cursor will appear
when the mouse hovers over a text field.
Example
The hide( )
method is used to conceal the
default system mouse pointer, typically in order to replace it with a
custom pointer. In Flash, a custom pointer is nothing more than a
movie clip that follows the mouse. Using the
mouseMove
event, we can cause a movie clip to
follow the mouse by updating the clip’s _x
and _ y
properties with each passing frame. The
following code demonstrates the technique:
// Code on the clip that acts as the custom pointer onClipEvent (load) { Mouse.hide( ); } onClipEvent (mouseMove) { _x = _root._xmouse; _y = _root._ymouse; updateAfterEvent( ); }
It may also be desirable to hide the custom pointer when the mouse is inactive, say, because the pointer has left the Flash Player’s active stage area, in which case the system pointer appears and there are two pointers on screen. The following code shows how to adapt the previous code to hide the cursor after 5 seconds of inactivity:
onClipEvent (load) { Mouse.hide( ); } onClipEvent (enterFrame) { if (getTimer( ...
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.