Search code examples
flashactionscript-3mouse

Hand Cursor when rolling over MovieClips in AS3


My goal is to simply have the cursor swap to be a hand (pointer) when I roll over a MovieClip. Obviously I could use SimpleButton, but the situation is that I have some enemies that are obviously MovieClips, and when I select an ability to use I want the mouse to show as a pointer when I roll over them.

I assumed this would work:

var mc:MovieClip = new MovieClip();

mc.graphics.beginFill(0);
mc.graphics.drawRect(0,0,50,50);
mc.graphics.endFill();

mc.useHandCursor = true; // <---- doesn't work?

addChild(mc);

mc.addEventListener(MouseEvent.CLICK, _click);
function _click(e:MouseEvent):void
{
    trace('a');
}

There are workarounds such as adding a button into the enemy MovieClip and then removing it. Just seems there's an inbuilt way I'm missing.

Thanks.


Solution

  • I think it's mc.buttonMode = true;