/ Published in: ActionScript 3

It's very useful if you build a FLV player for example, and want to convert the time into minutes:seconds (example: 6:13)
//apply it to your project like this (and don't forget to import the class):
time.text = TimeUtil.getTimecode(timeValue);
//apply it to your project like this (and don't forget to import the class):
time.text = TimeUtil.getTimecode(timeValue);
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
package com.vamapaull.utils { public class TimeUtil { public static function getTimecode(value:Number):String { var t:Number = Math.round(value), min:Number = Math.floor(t/60), sec:Number = t%60, tc:String = ""; if(min < 10) tc += "0"; if(min >= 1) { if (isNaN(min) == true) tc += "0"; else tc += min.toString(); } else tc += "0"; tc += ":"; if(sec < 10) { tc += "0"; if (isNaN(sec) == true) tc += "0"; else tc += sec.toString(); } else { if (isNaN(sec) == true) tc += "0"; else tc += sec.toString(); } return tc; } } }
URL: http://blog.vamapaull.com/timecode-utility/
Comments
