I’m trying to make a timer that when started, begins a movie and tracks its progression in seconds, minutes, and hours. I’ve been using SetInterval to count tenths of a second for accuracy. My problem is the timer doesn’t seem to be keeping time correctly. I let it run for 30 seconds against my windows clock and always comes like 5-6 seconds short. Anyone know whats up with this? Would getTimer() be more accurate??
playInterval = setInterval(timer, 100);
function timer () {
tenths++;
if (tenths>= 10) {
tenths= 0;
seconds++;
}
if (seconds >= 60) {
seconds = 0
minutes++;
}
if (minutes >= 60) {
minutes = 0;
hours++;
}
// Format the digits properly
if (seconds <= 9) {
sec = "0" + seconds;
} else {
sec = seconds;
}
if (minutes <= 9) {
min = "0" + minutes;
} else {
min = minutes;
}
if (hours <= 9) {
hrs = "0" + hours;
} else {
hrs = hours;
}
timeToShow = hrs +":" + min + ":" + sec;
_root.timestamps_mc.video_mc.timer_txt.text = timeToShow;
updateAfterEvent();
}