AddThis Social Bookmark Button
Creating a new cursor

With the knowledge we have been accumulating to that point we are going to be able to replace the default mouse cursor and to create a new one. We are using the same movie than the one we used previously, in the code I have greyed out the previous code, as you can see it is very straightforward to change the aspect of the mouse cursor, the steps are :

1. We hide the normal mouse cursor using the hide method of the Mouse class. Note that to show it again you will need to use the show method.

2. Once the normal cursor is hidden we make sure that each time the mouse is moved we update the coordinates of the movie clip that we use to replace the normal cursor, this is done with the 2 lines :

cursor._x = _xmouse;
cursor._y = _ymouse;

3. Again we use updateAfterEvent to force a screen refresh for a smoother display of the cursor as it moves.

Mouse.hide();

onMouseMove = function () {
feedback.text = "You are moving your mouse";

cursor._x = _xmouse;
cursor._y = _ymouse;
updateAfterEvent();
};


onMouseDown = function () {
feedback.text = "You pressed the left mouse button";
};


onMouseUp = function () {
feedback.text = "You released your left mouse button";
};

myListener = new Object();
myListener.onMouseWheel = function () {
feedback.text = "You are playing with your mouse wheel";
};

Mouse.addListener(myListener);


Good luck :)



AddThis Social Bookmark Button
If you think this page is providing useful information, don't hesitate to leave a comment.
flashvalley
 
Copyright ©2006-2008 flashvalley.com - All rights reserved