I just wrote this incredibly verbose code to turn numbers like 2 into 02. Can you make this function shorter, please (maintaning the functionality)?
I've always done this by taking a string that is the maximum padded width of zeros containing all zeros, then appeneding the string to padded to the end of the zeros string and then using substring to get the right hand Length digits.
Something like:
function pad(num:int, length:unit):String{
var big_padded:String "0000000000000000000000000000" + num.toString();
return big_padded.substring(big_padded.length - length);
}