Return to Kroll Design home page

Flash Tutorials (with .FLA files included)

« Return

ActionScript 3

Custom Cursor

In Flash movies you can replace the Windows/Mac mouse cursor with one of your own. See Action Script below -- each statement has a corresponding comment to explain why it is used.

Download the FLA file

Here's the code from the main timeline:

// don't show the Windows or Mac mouse cursor, since we're using a custom cursor:

// call the moveCursor function in every frame:
addEventListener(Event.ENTER_FRAME, moveCursor);

// Only one object under the mouse have a mouseover state at any given point in time.
// We want a mouseover effect for the button, not the custom cursor.
// So, set the custom cursor's mouseEnabled to false, to prevent the mouseover effect of
// the button from flickering or failing altogether:
myCustomCursor_mc.mouseEnabled = false;

// Since the custom cursor consists of multiple pieces and layers, you need to
// set mouseChildren to false so that the entire cursor movie clip acts like one
// cohesive unit.  Not setting mouseChildren to false results in unwanted and
// sporadic mouseover effects on the button:
myCustomCursor_mc.mouseChildren = false; 

// move the custom cursor in each frame to be in the same X-Y location that the
// Windows or Mac cursor would be were it visible:
function moveCursor(event:Event)
		myCustomCursor_mc.x = mouseX;
	  myCustomCursor_mc.y = mouseY;	

Here's the code from the timeline for the custom cursor:

// this offsets one iteration of the contracting glow ring,
// so that the two iterations alternate:


« Return

©2012 Kroll Design    781.910.3694
Last modified: 12/31/1969 7:00 PM