Creating a custom cursor

Her we are going to create our custom curosr for a movie instead of the default cursor. So basically we are going to play arround with "Mouse" object.

So, lets get started.

1. create a new flash movie.
2. Create a movieclip and name it "myMouse_mc". Remember this is the name of the clip on stage. Actually I use the same name in the library too for less confusion.
3. Now make 1 more layer on the root timeline and name it "Actions" and the defalut layer should be renamed to "Gfx", just organising things.
4. In the actions layer type in the following code.
stop();
_root.onMouseMove = function() {
myMouse_mc._x = _root._xmouse;
myMouse_mc._y = _root._ymouse;
};
5. Now test the movie.You can see our new clip is going with the mouse, whereever my mouse goes.Nice.
6. But the move is not smooth, its bit jerky.So to make it smooth we will add one more line to it as

updateAfterEvent();

7. so the final script will look like

stop();
_root.onMouseMove = function() {
myMouse_mc._x = _root._xmouse;
myMouse_mc._y = _root._ymouse;
updateAfterEvent();
};

Now test the movie. Thistime our custom cursor moves smoothly.

8. Now for the last part. We need to hide our defalut mouse cursor. So add another line in the end as

Mouse.hide();

Now test the movie. Wow, you have created a cutom cursor for your movie. Change the movieclip as your liking, and you have a custom cursor of your choice. May be an animated cursor ! Thats really fun.

So the final script is

stop();
//making my mouse cursor to move with mouse
_root.onMouseMove = function() {
myMouse_mc._x = _root._xmouse;
myMouse_mc._y = _root._ymouse;
//making the move smooth
updateAfterEvent();
};
//finally hiding the original mouse cursor
Mouse.hide();

Happy flashing

Advertisements

Author: saumya

designer / developer / maker / educator @saumya

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s