1. Home
  2. Computing & Technology
  3. Animation

Creating a Custom Mouse Cursor in Flash

By , About.com Guide

3 of 7

Now that the easy part’s out of the way, we get to the fun stuff: the ActionScripting. Right-click on your custom cursor’s symbol, and open the Actions pane. We’ll start off with a simple onClipEvent:

onclipEvent (enterFrame) {
}

What we’re going to do is have the movie clip align its x and y coordinates (Cartesian, remember) with the X and Y coordinates of the mouse with each frame that Flash plays, so that no matter what position the mouse is in on each frame passed—or each time the same frame cycles—the custom cursor is there, tailing its exact position. That’s why we used the enterFrame event.

Next we’re going to add the code that tells it to align the movie clip’s x position with that of the mouse:

onclipEvent (enterFrame) {
_x = _xmouse;
}

_x is the Flash operator representing the x (horizontal) position of the object in question, measured in pixels from the left edge of the stage, while _xmouse is the Flash operator representing the x (horizontal) position of the mouse cursor in pixels from the left edge of the stage. We just told Flash to make the horizontal position of the cursor object the same as the horizontal position of the mouse.

Explore Animation
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Animation
  4. Flash Animation Tutorials
  5. Creating a Custom Mouse Cursor in Flash

©2009 About.com, a part of The New York Times Company.

All rights reserved.