I'm building a flash desktop Quiz app, and i want to calculate how long it took the user to finish the quiz. so i did this to calculate the duration between when the user opens the first frame and when he arrives at the last frame:
//Code in the first Frame:
var startTime:Date = new Date();
var startMinutes:Number = startTime.getMinutes();
var startSeconds:Number = startTime.getSeconds();
and this is the code in the last frame:
//Code in the last Frame:
var endTime:Date = new Date();
var endMinutes:Number = endTime.getMinutes();
var endSeconds:Number = endTime.getSeconds();
var minutesDuration:Number = endMinutes - startMinutes;
var secondsDuration:Number = endSeconds - startSeconds;
durationTextField.text=String(minutesDuration)+":"+String(secondsDuration);
The problem is with the durationTextField, it doesn't display the duration, sometimes it displays a random number like 2 or 3 and a lot of times it displays nothing, why is that? is there any better way to tackle this whole duration problem than why i did?