I wonder if you can get the number of milliseconds that have elapsed since an actionscript timer has started.
I want to set a simple label in flex that has the value of how long it wil take before the timer fires (again).
this is the code, at 'GET ELAPSED TIME', I need the time that the timer has been running (since it last fired the function):
var timer = new Timer (10000);
timer.addEventListener(TimerEvent.TIMER, foo);
timer.start();
var numberOfSeconds = timer.delay-timer.'GET ELAPSED TIME';
resetLabel.text = "only "+numberOfSeconds+" until foo fires";
Does this function to get the timers time exist and how is it called (google failed to answer me)?
There is no real property to get the remaining time of your Timer
. A workaround could be to add a check within your foo
function. A basic setup would look something like this:
var realDelay:int = 10000;
var timer:Timer = new Timer (1);
timer.addEventListener(TimerEvent.TIMER, foo);
timer.start();
function foo(e:TimerEvent) : void
{
var realCount:int = Math.floor(timer.currentCount/realDelay);
var timeLeft:Number = (realDelay-timer.currentCount%realDelay);
resetLabel.text = "Real count: " + realCount + ", milliseconds left: " + timeLeft;
}