在as3中为数字添加千位分隔符

<mx:NumberFormatter id="myFormatter"      decimalSeparatorFrom="."      decimalSeparatorTo="."      precision="-1"      rounding="none"      thousandsSeparatorFrom=","      thousandsSeparatorTo=","      useNegativeSign="true"      useThousandsSeparator="true"/>

其中rounding是四舍五入,有“none”,“up”,“down”和“nearest”四种格式,分别表示无,向上取,往下取和最近的;而precision是精度,“-1”表示按原精度不变。其它属性参考API文档。
在as中用trace(myFormatter.format(12346.3254));
输出:12,346.3254;

猜你喜欢

转载自liugang-ok.iteye.com/blog/1165788