数字更改视图的AS3帮助

时间:2014-11-25 15:37:09

标签: actionscript-3

我想将15.24514的观看次数更改为15.24

    public function jackpotstring():String {

        var myPattern:RegExp = /./; 
        var jp:Number = jackpot * denom;
        jp = Math.round(jp * 100)/100;
        jp = jp / 100;
        var s:String = String(jp);
        return s;


    }

1 个答案:

答案 0 :(得分:0)

检查:

public function roundTo(number:Number, decimals:int):Number {
    var roundFactor:Number = Math.pow(10, decimals)
    return Math.round(number * roundFactor) / roundFactor;
}

或者你可以使用Number方法toFixed():

var formattedNumber:String = someNumber.toFixed(2);