Posted By

fergc on 05/25/12


Tagged

as3


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

PawelGIX
tamak


Milliseconds to mm:ss:mmmm


 / Published in: ActionScript 3
 

Milisegundos a formato minutos, segundos y milesimas

  1. public function toTimeCode(milliseconds:Number):String
  2. {
  3. var seconds:int = Math.floor((milliseconds/1000) % 60);
  4. var strSeconds:String = (seconds < 10) ? ("0" + String(seconds)):String(seconds);
  5. var minutes:int = Math.round(Math.floor((milliseconds/1000)/60));
  6. var strMinutes:String = (minutes < 10) ? ("0" + String(minutes)):String(minutes);
  7. var strMilliseconds:String = milliseconds.toString();
  8. strMilliseconds = strMilliseconds.slice(strMilliseconds.length -3, strMilliseconds.length)
  9. var timeCode:String = strMinutes + ":" + strSeconds + ':' + strMilliseconds;
  10. return timeCode;
  11. }

Report this snippet  

You need to login to post a comment.