Creating Interaction with ActionScript > Creating a custom cursor
Creating a custom cursor
To hide the standard cursor (that is, the onscreen representation of the mouse pointer), you use the hide
method of the predefined Mouse object. To use a movie clip as the custom cursor, you use the startDrag
action.
To see an animated demonstration of a custom cursor, drag the mouse in the movie.
To create a custom cursor:
1 | Create a movie clip to use as a custom cursor. |
2 | Select the movie clip instance on the Stage. |
3 | Choose Window > Actions to open the Object Actions panel. |
4 | In the Toolbox list, select Objects, then select Mouse, and drag hide to the Script window. |
The code should look like this: | |
onClipEvent(load){ Mouse.hide(); } |
|
5 | In the Toolbox list, select Actions; then drag startDrag to the Script window. |
6 | Select the Lock Mouse to Center box. |
The code should look like this: | |
onClipEvent(load){ Mouse.hide() startDrag("this", true); } |
|
7 | Choose Control > Test Movie to use the custom cursor. |
![]() |
Buttons will still function when you use a custom cursor. It's a good idea to put the custom cursor on the top layer of the Timeline so that it moves in front of buttons and other objects as you move the mouse in the movie.
For more information about the methods of the Mouse object, see their entries in the ActionScript dictionary: Overview.