Custom Mouse Cursor
Description: Remove the default mouse cursor and replace it with your own
Author: John Bezanis
Added: March 1st 2007
Version: Flash 8
This simple tutorial demonstrates how to replace the default cursor with a custom one.
First, draw the cursor you'd like to use. Select the graphic using the Selection Tool. Right-Click and select Convert to symbol. Set the name to cursor, the type to Movie Clip, and click Export for ActionScript. Make sure the Identifier is set to cursor. Click OK. Double-click the newly created symbol open and to edit the cursor's position. Move the position so it suits your needs, and double-click the stage outside of the graphic area. This will bring you back to the main level. Now that the cursor graphic is finished, click it and hit delete on the keyboard. It is ok to delete the graphic because it has been added to the library, so we can re-add it using actionscript. Click somewhere on th stage and open up the Actions Frame and insert the following code:
- Mouse.hide();
- this.attachMovie("cursor", "cursor", this.getNextHighestDepth());
- cursor.onMouseMove=function(){
- cursor._x=_xmouse;
- cursor._y=_ymouse;
- cursor.swapDepths(this.getNextHighestDepth());
- updateAfterEvent();
- }
The source file is available below for download.
Download Source File
Comments
how would you keep the cursor on top if there is other action script also calling for the next highest depth, (see "Instantiating an Object").
March 22nd 2007 11:03PM - Mr. P
I've added in the line cursor.swapDepths(this.getNextHighestDepth()); to keep the cursor at the highest depth.
March 23rd 2007 07:03AM - John
How would you change the color of your custom mouse while your using it in your movie? I'm making a "coloring book" and want my custom mouse to change to the color that is being clicked.
October 10th 2007 12:10AM - Ronda
How do you prevent it from braking once you right click?
November 4th 2007 01:11AM - Tommy
Why not place an instance of the cursor symbol, give it an instance name of "cursor_mc" and simplify your code to just:
cursor.startDrag("true");
Mouse.hide();
rt
cursor.startDrag("true");
Mouse.hide();
rt
November 12th 2007 01:11AM - rt
rt, yeah that works as well.
November 12th 2007 08:11AM - John
I put it the code it won't work
December 21st 2007 08:12PM - Flashy Games
Now it works thanks for putting up the code!
December 21st 2007 09:12PM - Flashy Games
how make visual effects and advance Mouse cursor by ActionScript2.0
February 4th 2008 03:02AM - om Prakash
cool codes. john's code is for the use of cursor's meaning. By using cursor.startDrag("true"); it's another meaning already. it's all depends on wad function you want then use the appropriate methods ;-)
March 31st 2008 03:03AM - xy
i made a button for a cursor but when i click on things it only activates the cursor button, and not things in the movie. how do i get the cursor to do something when mouse is clicked along with whatever is clicked on??
April 12th 2008 03:04AM - chris
I haven't tried this yet, but does the cursor appear on all frames/keyframes, or just the frames I insert it into from the library.
Also, I have just read the last message, I will need my cursor to be able to click on buttons, will this work?
Thankyou to anyone who can take the time to reply to me.
Also, I have just read the last message, I will need my cursor to be able to click on buttons, will this work?
Thankyou to anyone who can take the time to reply to me.
October 2nd 2008 01:10PM - Ollikx
There's an error saying:
**Error** Symbol=cursor, layer=Layer 1, frame=1:Line 1: Clip events are permitted only for movie clip instances
onClipEvent (load)
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 3: Statement block must be terminated by '}'
cursor.onMouseMove=function(){
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 9: Syntax error.
Total ActionScript Errors: 3 Reported Errors: 3
I have no idea what this is about...
Help.
**Error** Symbol=cursor, layer=Layer 1, frame=1:Line 1: Clip events are permitted only for movie clip instances
onClipEvent (load)
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 3: Statement block must be terminated by '}'
cursor.onMouseMove=function(){
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 9: Syntax error.
Total ActionScript Errors: 3 Reported Errors: 3
I have no idea what this is about...
Help.
December 24th 2008 03:12PM - aledTH
It works now. Thanks alot!!!
December 24th 2008 03:12PM - aledTH
Flash 8 code:
Mouse.hide();
this.attachMovie("cursor", "cursor", this.getNextHighestDepth());
cursor.onMouseMove=function(){
cursor._x=_xmouse;
cursor._y=_ymouse;
cursor.swapDepths(this.getNextHighestDepth());
updateAfterEvent();
}
should work
Mouse.hide();
this.attachMovie("cursor", "cursor", this.getNextHighestDepth());
cursor.onMouseMove=function(){
cursor._x=_xmouse;
cursor._y=_ymouse;
cursor.swapDepths(this.getNextHighestDepth());
updateAfterEvent();
}
should work
August 15th 2009 10:08PM - Kyle Flashman
ggg
November 6th 2009 09:11AM - vigrx
how do would i make it so that when the down key is pressed it will goto frame 2?
December 1st 2009 01:12AM - JAYD3N
I have bookmarked your site. Thanks for sharing
December 13th 2009 08:12AM - dental
How would you change the color of your custom mouse while your using it in your movie? I'm making a "coloring book" and want my custom mouse to change to the color that is being clicked.
December 17th 2009 02:12AM - Dating tips
Really useful. This article will help me a lot. Thank you.
December 26th 2009 06:12AM - Translation Service
That's really great, I am happy to find it, thanks for sharing it.
December 26th 2009 12:12PM - Designer Eyewear
It's nice tutorial
January 24th 2010 07:01AM - evening dresses
Custom Mouse Cursor
January 24th 2010 09:01AM - Ares 1
It's nice tutorial
January 25th 2010 07:01AM - <a href="http://w
It's nice tutorial
January 25th 2010 07:01AM - Movers Manhattan
This tutorial is easy to adapt.
January 25th 2010 10:01PM - film
Special thank for good post.
February 5th 2010 09:02PM - โหลดเพลงà
Thank for the information
February 6th 2010 07:02AM - โหลดเพลงm
Special thank for good post.
February 10th 2010 03:02AM - โหลดเพลงà
Special thank for good post.
February 10th 2010 08:02AM - โหลดเพลงà
great help, but now i can´t get to unattach the movie again on mouseclick.
somebody got an idea?
i want the cursor to be standard again by clicking a button.
Nice, youre so cool!
somebody got an idea?
i want the cursor to be standard again by clicking a button.
Nice, youre so cool!
February 19th 2010 06:02AM - Ben
Add a Comment





