In this tutorial, we’ll learn how to create a simple cursor in Flash without ’startDrag’ function.

First of all, create a new Actionscript 2.0 Flash file.

Draw the cursor you wish to use in your flash movie. It can be whatever you want it to be. I suggest leaving a small arrow in the top right corner so you know your actual position of the mouse in the movie. Convert it to a MovieClip and name it to whatever you want. Go into your MovieClip and make sure the tip of the mouse is exactly in the middle of the black cross. Go back to main scene and clip your mouse once (click the Flash Mouse). Press F9 for the actions panel. Add this code to the movieclip:

onClipEvent(enterFrame){
 this._x = _root._xmouse;
 this._y = _root._ymouse;
}

Also, if there is more than one frame in your main movie, add this to the first frame:

stop();

And if you want to hide the Mouse, use:

Mouse.hide();

Test the movie and your mouse should be the movieclip you created!



Download the sourcecode if you had any problem.

Share this post:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • Reddit
  • Live
  • E-mail this story to a friend!
  • Print this article!

Related Posts:

This entry was posted on Friday, July 18th, 2008 at 10:56 am.
Categories: Flash.

4 Comments, Comment or Ping

  1. I need to thank you for this tutorial.

  2. Also (though it can add lag), using “updateAfterEvent();” makes it smoother after the moving to the mouse code. :)

  3. First of all, thanks for commenting.

    To make it smoother, just increase the frame rate. :)

Reply to “Creating a Custom Cursor”