timeelapsed

calculate elapsed time in flash


I am building a quiz and i need to calculate the total time taken to do the quiz. and i need to display the time taken in HH::MM::SS..any pointers?


Solution

  • new Date().time returns the time in milliseconds.

    var nStart:Number = new Date().time;
    
    // Some time passes
    
    var nMillisElapsed:Number = new Date().time - nStart;
    
    var strTime:String = Math.floor(nMillisElapsed / (1000 * 60 * 60)) + "::" + 
       (Math.floor(nMillisElapsed / (1000 * 60)) % 60) + "::" + 
       (Math.floor(nMillisElapsed / (1000)) % 60);