Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 332
Marty Avatar asked May 09 '11 01:05

Marty


2 Answers

I think it's mc.buttonMode = true;

like image 149
jhocking Avatar answered Nov 16 '22 04:11

jhocking


Sometimes you will need to use also :

mc.mouseChildren=false;

To have handcursor over some movieclips, like movieclip with a textfield inside. -

like image 33
Bartek Avatar answered Nov 16 '22 02:11

Bartek