`

Thursday, September 23, 2010

as3 animated mouse cursor

In this lesson, let’s see how to build an animated mouse cursor

First, make a movieclip, give it an instance name of 'cursor_mc', draw any kind of arrow inside it and now for the code:

Mouse.hide(); // hide the default mouse cursor..

stage
.addEventListener(Event.ENTER_FRAME, onMove);

//This creates a listener on the stage, the event is Event.ENTER_FRAME, which is the new on.EnterFrame function, the listener calls the moveMouse function constantly because of it.

function onMove(event:Event) {
    cursor_mc.x = mouseX;
    cursor_mc.y = mouseY;

    //This sets the position of the cursor,

}

This is the end of the function.


Testing it should hopefully give you a working custom cursor.

Hope this helps and works.

Preview

Download .zip

No comments: