1 Reply Latest reply on Aug 15, 2011 6:53 AM by Manystems-Arjen

    Timer maximum delay

    Manystems-Arjen

      Hi,

       

      I have a class which calculates when a update events needs to be send.

      Sometimes this results in a large delay, for example 20 days.

       

      When i use this delay in a timer, the timer fires the TIMER event immediately.

      So I was wondering if there is a maximum value for the timer delay property.

      Since the delay is a number my guess was that the max numer value is also the max delay value.

       

      To test my issue just create a timer with delay "2572335030" and listen for the TIMER event.

      The number i "2572335030" used is a number generated by a class of mine, this is the first time i ran into this looping issue.

       

       

      Or use my example:

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                        xmlns:s="library://ns.adobe.com/flex/spark" 
                        xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
           
           <fx:Script>
                <![CDATA[
                     private var timer:Timer;
                     [Bindable]private var timerCount:int = 0;
                     protected function btnStart_clickHandler(event:MouseEvent):void     {
                          if(parseInt(txtTime.text) < Number.MAX_VALUE){
                               if(!timer)
                                    timer = new Timer(parseInt(txtTime.text));
                               timer.addEventListener(TimerEvent.TIMER,handleTime);
                               timer.start();
                          }
                     }
                     
                     private function handleTime(event:TimerEvent):void{
                          timer.stop();
                          timerCount++;
                          timer.delay = parseInt(txtTime.text);
                          timer.start();
                     }
                     
                     protected function btnStop_clickHandler(event:MouseEvent):void{
                          timerCount = 0;
                          timer.stop();                    
                     }
                     
                ]]>
           </fx:Script>
           
           <fx:Declarations>
                <!-- Place non-visual elements (e.g., services, value objects) here -->
           </fx:Declarations>
           <s:HGroup>
                <s:TextInput id="txtTime" text="2572335030"/>
                <s:Button id="btnStart" label="Start" click="btnStart_clickHandler(event)"/>
                <s:Button id="btnStop" label="Stop" click="btnStop_clickHandler(event)"/>
                <s:TextInput text="{timerCount}"/>          
           </s:HGroup>
      </s:Application>