I have an EnterFrame event, and I want to know the exact time between calls, so I will be able to animate objects more smoothly when the computer can't produce the desired framerate.
To be a little more specific.
currentTime = getTimer();
diff = currentTime - prevTime;
prevTime = currentTime;//update for next go around
EDIT
getTimer requires you import the package: flash.utils.getTimer;
You should use the inbuilt Timer function to call a method at a somehow* ENTER_FRAME
independent way.
var timer:Timer = new Timer(500, 0);
timer.addEventListener(TimerEvent.TIMER, timerHandler);
timer.start();
private function timerHandler(event:TimerEvent):void
{
// do something
// *EDIT* Thanks @Luke spotting this out (check comments)
event.updateAfterEvent();
}
*) Still you need to keep in mind the event handler will not be triggered between frames so in case your script is lagging (because of some other process) this call will also be delayed. To be precise, the method call will be approximated at the frame executed at the same time or right after the set delay time.
as the others stated, getTimer is the best way to go ... but i wanted to suggest something else: if you want to do time based animation, that are updated frame based, you might also try some of the bigger ActionScript tweening libraries, as the caurina Tweener ... they simply do that out of the box and provide other great features ...