0
votes

I have an Adobe AIR application with a chart component displaying some online data. The chart component has to display a bunch of parameters about 10 of them. The application has a timer to display current system time.

The chart component is invoked from the timer(using a bindable object) as shown below. A separate bindable object is used to prevent delay in timer.

private function onTimerEvent(event:TimerEvent):void

{   
    //Update time in screen

    oCurrDate = new Date();
    curTime = oDateformatter.format(oCurrDate).toString();
    oCurrDate = null;

    //oUpdate- Bindable object to inform chart about update
    //Call chart every 250 ms
    oUpdate.bUpdate = !oUpdate.bUpdate;  
}

Iam using a calllater function in chart's update event as shown below. updateParameter() will update the dataprovider of each of the parameter and draws it.

public function onUpdateEvent(evt:PropertyChangeEvent):void
{

//aPlotIndex set to 0 for first parameter

aPlotIndex.push(0);

this.callLater(updateParameter, aPlotIndex);  
}

The problem is the timer and chart updation stops after running 20 to 21 days. After 20 or 21 days, the update happens only on mouse move. When I moved mouse the time displayed & data in chart are updated.

I profiled the application and found that there is no memory leakage issues. I am logging all the errors but I didn't get any error in the log also. Everything seems weird.

  1. Is it because of using the calllater function.
  2. Is it that the timer is still running but frame update not happening.

I am using Flex SDK3.3 and Flex AIR version 2.0.4.13090.

Please guide me to resolve this issue.

1

1 Answers

0
votes

Please read the documentation for Timer.

The total number of times the timer is set to run. If the repeat count is set to 0, the timer continues indefinitely, up to a maximum of 24.86 days, or until the stop() method is invoked or the program stops. If the repeat count is nonzero, the timer runs the specified number of times. If repeatCount is set to a total that is the same or less then currentCount the timer stops and will not fire again.

The maximum is due to the max of an int, which is what the timer uses to store its current count. int has a max value of 2,147,483,647. 2147483647 / 24.86 days / 1440 minutes / 60 seconds /1000 milliseconds is equal to 1 (give or take, differences with the way the docs' number is rounded), which aligns with the fact that the internal clock stores its count per millisecond the Timer has run.

So you cannot set an option to fix this. Instead, you can work around it, assuming nothing actually relies on your timer's value. Each time the timer runs, call

timer.reset();
timer.start();

That will reset the timer to 0 and start it back up again, meaning you will never hit that 24.86 day limit, unless your delay is longer than that (which it cannot possibly be)

Additionally, I'd like to point out that the Flex and AIR versions you are running are severely out of date. Both are nearly 5 years old at this point. AIR may not even run properly on newer versions of Windows and OS X because of it (and won't run on mobile at all). Not a big deal if everything works, but always good to know (many posters on SO do not realize how out of date their Flex and AIR SDKs are)