Thursday, July 9, 2009
AS3 Timer accuracy
Thursday, July 9, 2009
I've just bit into some weirdness. I have a Timer that I want to fire every 100th of a second. So it would be new Timer( 10, x ); However when testing this isn't not accurate (I am printing the time to the screen). So if I drop the Timer down to fire every 7ms instead of 10, it aligns with my watch, my computer, and my stop watch on my iPhone.
That's great, but what when I move this to another machine? It will probably be slightly off.
What is even stranger is that when I do new Timer( 7, 1800 ); - it still reaches 18 seconds, even though it should have fired a complete before that.
Is there a really accurate way of timing something as close to possible? I know this is a pretty old topic, maybe someone has found something really reliable.
[July 10th Update]
I have decided to fire on every 10th of second. I'm losing a bunch of timing control, but it wasn't accurate enough anyway. Instead of working on reading the system clock and making dynamic adjustments on the fly, I've decided that increasing the delay of the timer will work as it's now only off a tiny bit compared to before. Of course the longer it runs, the more it will be off, but my timer isn't going to run for a very long time, thankfully.
That's great, but what when I move this to another machine? It will probably be slightly off.
What is even stranger is that when I do new Timer( 7, 1800 ); - it still reaches 18 seconds, even though it should have fired a complete before that.
Is there a really accurate way of timing something as close to possible? I know this is a pretty old topic, maybe someone has found something really reliable.
[July 10th Update]
I have decided to fire on every 10th of second. I'm losing a bunch of timing control, but it wasn't accurate enough anyway. Instead of working on reading the system clock and making dynamic adjustments on the fly, I've decided that increasing the delay of the timer will work as it's now only off a tiny bit compared to before. Of course the longer it runs, the more it will be off, but my timer isn't going to run for a very long time, thankfully.
It still sucks, and while I can't expect any timer to be absolutely accurate for numerous reasons, I'd hope that in the future we're able to get something that is more precise, somehow, someway. FP11?
Labels: Timer Class
Comments:
There are currently 9 Comments:
-
Goose said...“This might have to do with the frame rate of your SWF. There is probably a way to increase the frame rate in your main AS file with the [SWF] meta data tag.”