开发者

AS3: cancel event

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;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜