• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 25. Storyboarding to Finished Project > Swapping the Mouse Pointer

Swapping the Mouse Pointer

To make it obvious where on the island the tank could be moved, I used several new Flash 5 features to swap the default mouse pointer for a custom icon.

Exercise 25.1 Creating a Custom Mouse Pointer

1.
Create a new movie clip, which will replace the default mouse pointer. It can be any shape and size.

2.
Drag an instance of the bullseye movie clip to the work area, but place it outside the stage so that it will be out of the way. Set the instance name to bullseye.

3.
To detect whether the mouse is positioned over the player1target movie clip, use the hitTest() function inside an onClipEvent(enterFrame) event on any movie clip (I put it on the player1target symbol for this project):

onClipEvent(enterFrame) {
    if (_root.player1target.hitTest(_root._xmouse, _root._ymouse, 
    true)) {
    } 
} 

4.
To make the default mouse pointer invisible, insert Flash 5’s new Mouse() object inside the if statement:

Mouse.hide(); 

5.
Tell the bullseye movie clip to start tracking the mouse pointer location by inserting the startDrag() function inside the if statement:

startDrag("_root.bullseye", true); 

6.
To make the bullseye movie clip visible, modify its _visible property by adding the following:

_root.bullseye._visible = true; 

Note

It is possible to hide a movie clip by setting the Alpha to 0% in the Effect panel or by setting its _alpha property. However, it’s better to set the _visible property to false if you want the movie clip to be fully invisible because setting the _alpha property requires more processing cycles.

7.
To swap the mouse pointer back to the original when the mouse is no longer over the player1target movie clip, add the following code inside the onClipEvent(enterFrame) event (see Figure 25.2):

else {
        _root.bullseye._visible = false; 
        stopDrag; 
        Mouse.show(); 
    } 
} 

Figure 25.2. When the mouse is positioned over the player1target or player2target movie clips, the mouse pointer is swapped with the bullseye movie clip.



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint