[F8] reformat integer to money string
I'm working in flash 8 and as1.
I'm using this code that I found on the web..
Basically I'm just reformatting an integer to a money formatted string. The thing this code doesn’t do is add commas to the number. (Example: 1000 will return $1000.00)
Does anybody know how I may update this code to include commas in its output?
Thanks!
PHP Code:
function moneyFormat(num){
valor = String (Math.round(num * 100) / 100);
dot = valor.indexOf(".");
money = "$";
if(dot == -1){
valor += ".0";
}
temp = valor.split(".");
addDecimals = 2 - temp[1].length;
for(i=1; i<= addDecimals; i++){
valor += "0";
}
return money+valor;
};