Let's say I want a Sprite to act as a button and I want this Sprite to be able to be disabled. Like so:
public class Button extends Sprite
{
private v开发者_如何学运维ar _disabled:Boolean = false;
public function get disabled():Boolean
{
return _disabled;
}
public function set disabled( disable:Boolean ):void
{
_disabled = disable;
}
}
and then somewhere I do:
var myButton:Button = new Button();
myButton.addEventListener( MouseEvent.CLICK, _someClickHandler );
then when I disable the button like so:
myButton.disabled = true;
... how can I make it, so that my Sprite doesn't fire of a MouseEvent.CLICK? Or should I perhaps rethink my design?
try this.
myButton.mouseEnabled = myButton.mouseChildren = false;
精彩评论