Is there some kind of Format(Object, "format string") method in flash?

What I am trying to accomplish is the following;

Code:
Var nNumber : Number = 1234567890;
Var nNumber2 : Number = 7;

trace (format(nNumber, "#,###,###,###,##0"));
trace (format(nNumber2, "#,###,###,###,##0"));
output should be:
Code:
1,234,567,890
7
Anyone know of a way to do this or will i have to write my own function?