Wednesday, April 23, 2008

Showing the hand cursor on a Sprite with Text in it

In Actionscript 3, you don't automatically get a hand cursor over a sprite/movieclip, even if it has a MouseEvent.CLICK event listener attached to it. You have to set two properties in order to see the hand cursor:

var sp:Sprite = new Sprite();
sp.buttonMode = true;
sp.useHandCursor = true;

However, this doesn't help if you have any content within the sprite that could be clickable/selectable. To get the hand cursor when the sprite has children, you must also do:

sp.mouseChildren = false;

And depending on the events attached, you may also need:

sp.mouseEnabled = true;

No comments: