Task: Full-Time Custom Cursor

I l @ ve RuBoard

So what if you want to replace the cursor throughout the entire Flash movie. This is the easiest case. All you need to do is place a cursor movie clip across all the frames of your movie and attach a script to it.

  1. Start with a new Flash movie.

  2. Create a movie clip to replace the cursor. You can use a simple arrow. Be sure to position the arrow within the movie clip so that the crosshairs are at the tip as shown in Figure 13.1.

  3. Back at the root level, start building a script for the movie clip. This begins with code to hide the real cursor and move this movie clip to the front:

     onClipEvent(load) {     // hide the real cursor     Mouse.hide();     // bring this movie clip to the front     this.swapDepths(99999); } 
  4. The script continues with the main enterFrame handler. This positions the movie clip to where the cursor would have been:

     onClipEvent(enterFrame) {     // follow the mouse     this._x = _root._xmouse;     this._y = _root._ymouse; } 
  5. The last part of the movie clip script restores the real cursor when the movie clip ends. If your movie truly uses the custom cursor during the entire movie, you will never need this. However, if you only place the cursor movie clip on some of the frames, this is necessary or you will leave the user without any cursor at all.

     onClipEvent(unload) {     // show the real cursor again     Mouse.show(); } 
  6. Test your movie or look at 13fulltimecursor.fla.

I l @ ve RuBoard

Sams Teach Yourself Flash MX ActionScript in 24 Hours
Sams Teach Yourself Flash MX ActionScript in 24 Hours
ISBN: 0672323850
EAN: 2147483647
Year: 2002
Pages: 272

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net