views:

140

answers:

1

Hi all,

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 var _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?

+2  A: 

try this. myButton.mouseEnabled = myButton.mouseChildren = false;

Chris Gutierrez
sweet! works like a charm. thanks a lot!
fireeyedboy