EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 567

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Creating interactivity and visual effects 567
4. Select Frame 1 of the Timeline, and type the following code in the Actions panel:
Mouse.hide();
cursor_mc.onMouseMove = function() {
this._x = _xmouse;
this._y = _ymouse;
updateAfterEvent();
};
The Mouse.hide() method hides the pointer when the movie clip first appears on the
Stage; the
onMouseMove function positions the custom pointer at the same place as the
pointer and calls
updateAfterEvent() whenever the user moves the mouse.
The
updateAfterEvent() function immediately refreshes the screen after the specified
event occurs, rather than when the next frame is drawn, which is the default behavior. (See
updateAfterEvent function in the ActionScript 2.0 Language Reference.)
5. Select Control > Test Movie to test your custom pointer.
Buttons still function when you use a custom mouse pointer. Its a good idea to put the
custom pointer on the top layer of the timeline so that, as you move the mouse in the SWF
file, the custom pointer appears in front of buttons and other objects in other layers. Also, the
tip of a custom pointer is the registration point of the movie clip youre using as the custom
pointer. Therefore, if you want a certain part of the movie clip to act as the tip of the pointer,
set the registration point coordinates of the clip to be that point.
For more information about the methods of the Mouse class, see Mouse in the
ActionScript 2.0 Language Reference.
Getting the pointer position
You can use the _xmouse and _ymouse properties to find the location of the pointer in a SWF
file. These properties could be used, for example, in a map application that gets the values of
the
_xmouse and _ymouse properties and uses the values to calculate the longitude and
latitude of a specific location.

Table of Contents

Related product manuals