Thursday, December 17, 2009

Display a number with a fixed number of digits after the decimal point in AS 3.0

if you want to display a number with a fixed number of digits after the decimal point in AS 3.0
Sample code:

var num:Number = 12.65869;
var fix_num = num.toFixed(2);
trace("num:"+num);
trace("fix_num:"+fix_num);


//output will be:
num:12.65869
fix_num:12.65

No comments:

Post a Comment