Monday, February 1, 2010

Got Timecode?

Here is a simple function that takes the ns.time value and turns it into a timecode string. This would actually make a good class.
[as]function getTimecode(theTime:Number):String {
var t:Number = Math.round(theTime);
var min:Number = Math.floor(t/60);
var sec:Number = t%60;
var s:String = “”;
if(min < 10) {
s += "0";
}
if(min >= 1) {
s += min.toString();
}
else {
s += “0″;
}
if(sec < 10) {
s += “0″;
s += sec.toString();
}
else {
s += sec.toString();
}
return s;
}[/as]

No comments:

Post a Comment