How is the running time of the virtual machine calculated vs. how system time is calculated? I know I can get the current running time of the AVM by calling:
getTimer();
And I can get the current unix system time by doing:
new Date().getTime();
I know that the Timer class and Event.ENTER_FRAME event each come with their ups and downs, but I figured the 2 values I was comparing should stay consistently relative to each other. Here’s how I’m testing it:
private var _appRunTime:int;
private var _appStartTime:int;
private var _systemTime:int;
private var _systemCurrentTime:int;
//called at application launch
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
_systemTime = new Date().getTime();
_appStartTime = getTimer();
}
//called on button click to see values
protected function button1_clickHandler(event:MouseEvent):void
{
_systemCurrentTime = new Date().getTime();
_appRunTime = getTimer();
trace(_systemCurrentTime - _systemTime, _appRunTime - _appStartTime);
}
I don’t understand why those numbers would slowly get out of sync. Using that code, I’ve found, at least on my computer, that the values grow apart from each other by about 3 milliseconds per minute, with the value coming from system time being the higher value and the value coming from AVM time being the lower.
Can anyone offer me an explanation what those are calculated on and why there would be that small, yet growing gap in their values as time passes?
On my system the same code gives no difference between
getTimer()andgetTime()after ~10 mins the difference is always between 0 and 1 ms.
Maybe it’s an issue of you system or the specific to the player you’re running?
I’m running flash player 11 on Win 7 x64.