The problem seems to be somewhere else and not in the Button. Run the
following application, then click on the button to disbale it, then click
again when it's disabled. For me it behaves as expected, I don't get any
Click events for the clicks I do while the button is disabled.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="vertical"
creationComplete="init()">
    <mx:Script>
        <![CDATA[

            private var timer:Timer;

            private function init():void
            {
                timer = new Timer(3000, 1);
                timer.addEventListener(TimerEvent.TIMER,
timer_timerHandler);
            }

            private function logClick():void
            {
                logger.text += (new Date()).toTimeString() + " : Click\n";
                timer.start();
                btn.enabled = false;
            }

            private function timer_timerHandler(e:TimerEvent):void
            {
                logger.text += (new Date()).toTimeString() + " : Timer\n";
                btn.enabled = true;
            }
        ]]>
    </mx:Script>

    <mx:Button id="btn" label="Click Me" click="logClick()" />
    <mx:TextArea id="logger" width="400" height="400" />
</mx:Application>


Haykel Ben Jemia

Allmas
Web & RIA Development
http://www.allmas-tn.com




On Tue, Feb 17, 2009 at 8:33 AM, giladozer <gilado...@yahoo.com> wrote:

>   Thanks Alex for the quick response.
> However, the button is supposed to turn enabled after the result is
> returned.
> The problem is that while it looks like the button is disabled -
> clicking on it results in entering to the function which listens to it.
> Moreover, I logged/traced the time the the button turns back to enable
> + the time entering to the function that listens to it -
> it's exactly the same - by the millisecond.
> meaning - i can't event log the time the button was clicked - cause
> the mouse click event is only dispatched after the button turned enable.
>
> one last thing - I found a workaround by removing the eventListener
> when the button is disabled , and adding it back with a timer that
> starts counting after it turned enabled in ticks of 100ms. ( the the
> clicks are not listened in that time space of when the button turned
> enable and 100ms after that).
> The thing is that i don't want to use a timer... it's a very ugly
> solution.
>
> Thanks again,
> Gilad
>
>  
>

Reply via email to