How do you create a time counter in as3? Some simple search on google will point you to the AS3 class Timer that actually is a counter of events and not a proper time counting utility.
I have seen this http://blogs.adobe.com/pdehaan/2006/07/using_the_timer_class_in_actio.html and I am a little worried by the fact that it is official documentation that should work.
Q: Where exactly is the problem?
A: The Timer class executes operations in a stack of events and if you have a pretty heavy application I can bet the timer will distort your time if you use it to count seconds, milliseconds or whatever.
If you're looking to accurately measure short intervals of time you just use the getTimer()
function (flash.utils.getTimer
), which returns the number of milliseconds elapsed since Flash player started. The prototypical simple StopWatch class is:
public class StopWatch {
private var _mark:int;
private var _started:Boolean = false;
public function start():void { _
mark = getTimer();
_started = true;
}
public function get elapsed():int {
return _started ? getTimer() - _mark : 0;
}
}
More Info:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With