Ah, the joy of finding a simple method to make life easier.
Now I have always wanted the Ability to get just a few numbers from a number like 3.14567545645. I knew there must be a way to do this and now I just found it.
function toFixed(fractionDigits:uint):String
So You can do the following:
he following example shows how toFixed(3) returns a string that rounds to three decimal places.
var num:Number = 7.31343;
trace(num.toFixed(3)); // 7.313
The following example shows how toFixed(2) returns a string that adds trailing zeroes.
var num:Number = 4;
trace(num.toFixed(2)); // 4.00
The Wonders of Life in As3.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment