Top RIA blogs award

Top RIA blogs

Confessions of an Flash Addict Rotating Header Image

Changing the native cursor in FP10

I just found out you can natively change the mouse cursor in Flash.
This is handy if you want to have a different cursor when going over specific buttons or other DisplayObjects and don’t want to mess about with attaching clips to your mouse position.

For documentation please go here
Below is some quick code and an example:

_arrow.addEventListener( MouseEvent.MOUSE_OVER, arrowOver );
_button.addEventListener( MouseEvent.MOUSE_OVER, buttonOver );
_hand.addEventListener( MouseEvent.MOUSE_OVER, handOver );
_iBeam.addEventListener( MouseEvent.MOUSE_OVER, beamOver );

_arrow.addEventListener( MouseEvent.MOUSE_OUT, function(e:MouseEvent){Mouse.cursor = MouseCursor.AUTO; } );
_button.addEventListener( MouseEvent.MOUSE_OUT, function(e:MouseEvent){Mouse.cursor = MouseCursor.AUTO; } );
_hand.addEventListener( MouseEvent.MOUSE_OUT, function(e:MouseEvent){Mouse.cursor = MouseCursor.AUTO; } );
_iBeam.addEventListener( MouseEvent.MOUSE_OUT, function(e:MouseEvent){Mouse.cursor = MouseCursor.AUTO; } );

function arrowOver(e:MouseEvent):void {
Mouse.cursor = MouseCursor.ARROW;
}
function buttonOver(e:MouseEvent):void {
Mouse.cursor = MouseCursor.BUTTON;
}
function handOver(e:MouseEvent):void {
Mouse.cursor = MouseCursor.HAND;
}
function beamOver(e:MouseEvent):void {
Mouse.cursor = MouseCursor.IBEAM;
}

2 Comments on “Changing the native cursor in FP10”

  1. #1 jankees
    on Nov 16th, 2009 at 7:40 am

    cool, but why do you put it in a Array?

  2. #2 Sidney de Koning
    on Nov 16th, 2009 at 10:44 am

    No reason actually, ill clean up the code :)

Leave a Comment