Using Lingo for Animated Cursors


Using Lingo for Animated Cursors

If you've created an animated cursor cast member (covered in Chapter 4, "Animating Sprites"), you can activate it by using the cursor command in a handler.

The following example assumes that you want an animated cursor to replace the normal cursor when the mouse pointer rolls over a particular sprite (which we'll call the rollover target ), and that you want the normal cursor to return when the mouse pointer leaves the sprite. Once you see how the cursor command works, you can include it in other scripts that use different event handlers.

To activate an animated cursor on rollover:

  1. Create an animated cursor.

    (For details, see "To create an animated cursor" in Chapter 4.)

  2. In the Cast window, name the animated cursor cast member.

    You can name it whatever you like, but in this example, it will be named myCursor. (Although a cast member name can be more than one word, it's a good idea to make it a single word if you're going to use the name in a Lingo script.)

  3. In the Score or on the Stage, select a sprite to be the rollover target.

  4. Choose New Behavior from the Behaviors pop-up menu on the Sprite toolbar.

    A Script window opens.

  5. Type the following scriptconsisting of two handlersin the Script window, changing Director's default text where necessary ( Figure 15.62 ):

    Figure 15.62. This script causes the normal cursor to be replaced by a cursor cast member when the mouse pointer rolls over the sprite to which the script is attached.


     on mouseWithin    cursor (member "myCursor") end on mouseLeave    cursor -1 end 

    (If your cursor cast member is named something other than myCursor, change the script accordingly .) The command cursor -1 restores the default arrow cursor.

  6. Close the Script window.

  7. Rewind and test the movie.

    Whenever the mouse pointer moves onto the rollover target, the animated cursor appears; when it leaves the rollover target, the normal cursor returns ( Figure 15.63 ).

    Figure 15.63. The cursor changes when it rolls over the sprite.


graphics/tick.gif Tip

  • The cursor command works with nonanimated cursors as well. Any 1-bit cast member can be made into a cursor by means of the cursor command, so long as it's no larger than 16 pixels square.


Macromedia Director MX for Windows and Macintosh. Visual QuickStart Guide
Macromedia Director MX for Windows and Macintosh. Visual QuickStart Guide
ISBN: 1847193439
Year: 2003
Pages: 139 © 2008-2017.
If you may any questions please contact us: