Basically the question could more probably be more accurately asked, how do I simply disable a button and then re-enable it? I've tried setting buttonMode to false, mouseChildren to false and enabled to false. Nothing works. I realize I could just remove the event listeners, but surely there is a more elegant and efficient way. As removing the event listeners would force me to keep track of what functions pertain to certain button states and have to add and remove them over and over again, which seems clunky.
Is there a way to set a flag that makes the temporarily disables any eventListeners an object might have, and then simply turn them on again? I was under the misconception that adding rollOver events etc.. to a MovieClip converts it in theory to a button, in which can be easily turned off with the enabled property. Also, I can't use SimpleButton, as I need more flexibility than it provides.
I've created a custom class that does handle all this functionality, and makes life more simple, but I'm wondering if there as an out-of-the-box official way.
Below is an isolated example, that uses a MovieClip on the stage with an instance name of iPoo, where the events always fire regardless of what gets set when you click the button:
iPoo.addEventListener(MouseEvent.ROLL_OVER, pooRollOver);
iPoo.addEventListener(MouseEvent.ROLL_OUT, pooRollOut);
iPoo.addEventListener(MouseEvent.CLICK, pooClick);
function pooRollOver(_event:MouseEvent):void
{
iPoo.alpha = 0.5;
}
function pooRollOut(_event:MouseEvent):void
{
iPoo.alpha = 1;
}
function pooClick(_event:MouseEvent):void
{
trace("Poo");
iPoo.enabled = false;
iPoo.buttonMode = false;
iPoo.mouseChildren = false;
}