假设我想要一个Sprite充当按钮,我希望能够禁用此Sprite。像这样:
public class Button extends Sprite
{
private var _disabled:Boolean = false;
public function get disabled():Boolean
{
return _disabled;
}
public function set disabled( disable:Boolean ):void
{
_disabled = disable;
}
}
然后我在某处:
var myButton:Button = new Button();
myButton.addEventListener( MouseEvent.CLICK, _someClickHandler );
然后当我像这样禁用按钮时:
myButton.disabled = true;
...我该如何制作它,以便我的Sprite不会触发MouseEvent.CLICK? 或者我应该重新考虑我的设计?
答案 0 :(得分:2)
试试这个。
myButton.mouseEnabled = myButton.mouseChildren = false;