home support FAQ resources services partners contact us contact us
 Flash MX Previous  Next  
 Tutorial

Chapter 14 272

To create a custom cursor, you design the cursor movie clip on the stage. Then in ActionScript you hide the standard cursor and track the movement of the custom cursor. To hide the standard cursor, you use the hide method of the built-in Mouse object. To use a movie clip as the custom cursor, you use the startDrag action.

Actions attached to a movie clip to create a custom cursor (see customCursor.fla)

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 Actions panel if it is not already visible.

4 To hide the standard cursor, in the Actions toolbox, click the Objects category, click the Movie category, click Mouse, click Methods, and double-click hide.

The code should look like this:

onClipEvent(load){
Mouse.hide();
}
5 To apply the new cursor, in the Actions toolbox, click the Actions category, then click Movie Clip Control and double-click startDrag.

6 To limit the mouse movement, select the Expression box and type this for the target. Then select Lock Mouse to Center and Constrain to Rectangle, and enter values. For example, you might enter the following:

L: 0
T: 46
R: 400
B: 280

Your code should look like this:

onClipEvent (load) {

Mouse.hide();

startDrag(this, true, 0, 46, 400, 280);

}

7 Choose Control > Test Movie to test your custom cursor.

Buttons 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 the online ActionScript Dictionary in the Help menu.

Getting the mouse position

Tracking the mouse position gives you information about user movement in your movie. This information allows you to tie user behavior to movie events. You can use the _xmouse and _ymouse properties to find the location of the mouse pointer (cursor) in a movie. Each Timeline has an _xmouse and _ymouse property that returns the location of the mouse within its coordinate system. The position is always relative to the registration point. For the main Timeline (_level0), the registration point is the upper left corner.

The _xmouse and _ymouse properties within the main Timeline and a movie clip Timeline (mouse_position.fla)
Previous  Next  
Link Partners: Asia florist, Flowers to India, Hong kong flowers, Site submit, Cheap web hosting, China florist, Japan florist