开发者

AS3: cancel event

开发者 https://www.devze.com 2022-12-14 00:44 出处:网络
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:

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

精彩评论

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

关注公众号