This content has been marked as final.
Show 3 replies
-
1. Re: getting time elapsed in AS3
chukcha14 Feb 17, 2009 8:22 PM (in response to sneakyimp)var timer:Timer = new Timer(1000); //1000 milliseconds == 1 sec
timer.addEventListener(TimerEvent.TIMER, incrementCounter);
timer.start();
function incrementCounter(evt:TimerEvent):void {
this._someVariable++;
}
//as soon as the XMLSocket receives a response you would call
timer.removeEventListener(TimerEvent.TIMER, incrementCounter);
timer.stop();
//and print out your counter
trace(this._someVariable.toString()); -
2. Re: getting time elapsed in AS3
Some1Won Feb 17, 2009 8:24 PM (in response to sneakyimp)You could make a date object and grab the time from there. Or a more simple way I think is you can use getTimer(). I believe it’s under flash.utils.getTimer(). -
3. getting time elapsed in AS3
sneakyimp Feb 26, 2009 12:10 PM (in response to sneakyimp)Thanks for your response!
I took your advice on using getTimer() and it's working swell. However, I was kind of hoping for something that didn't require my Flash movie to be running the whole time. I have learned that you can create a new Date object and access its time property and that will return a value in milliseconds. You can later create a new Date object, access its time property, and compare the two:
var start:Date = new Date();
trace('start:' + start.time);
//calculate PI to a million digits or whatever
var end:Date = new Date();
trace('time elapsed:' + (end.time - start.time));
I haven't tested that, but I think it'll work.

