useButtonMode = true not working in AS3

In Actionscript 3, you may find yourself wondering why when you use “useHandCursor” on a MovieClip, the cursor remains an arrow on mouse_down.

In AS3, useHandCursor is a property of the SimpleButton class. if an object has “buttonMode” set to true, by default “useHandCursor” will also be true. If is is not set to buttonMode, setting “useHandCursor” to true will do nothing.

On objects that are set to buttonMode, setting “useHandCursor to false will prevent the cursor from changing to a hand on MOUSE_DOWN.

Example:

The orange square on the left does not have buttonMode applied, but it does have useHandCursor. Although it responds to the MOUSE_DOWN event the same as the blue square on the right, the cursor does not change to a hand.

The blue square on the right has buttonMode = true applied to it, and when dragged, the cursor will change to a hand.

Actionscript for this example:


function mouseDownHandler(event:MouseEvent):void
{
 
MovieClip(event.target).startDrag();
var draggedObject = DisplayObject(event.target);
stage.addChild(draggedObject);
}
function mouseUpHandler(event:MouseEvent):void
{
event.target.stopDrag();
 
}
square1.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
square1.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
square2.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
square2.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);

square1.useHandCursor=true;

square2.buttonMode=true;
//square1.useHandCursor=false; //use to turn OFF hand cursor on a button

buttomodeTest.fla.zip