AS3 Help For Commas

偶尔善良 提交于 2019-12-01 13:52:23

问题


I have this code and I want commas in my numbers. The jackpot is €169.85 but it is displayed as 16985 00 in the game. How to fix that?

public function jackpotstring():String {
    var myPattern:RegExp = /./; 
    var jp:Number = jackpot * denom;
    var s:String = jp.toFixed(2)+"";
    return s.replace(/[^A-Za-z0-9 \-_:]+/g, ' ');
}

回答1:


ou could try something like;

var jp:Number = jackpot * denom;
jp = Math.round(jp * 100)/100; // value should be something like 1698500
jp = jp / 10000; // value should be something like 169.85 now
var s:String = String(jp);
return s;


来源:https://stackoverflow.com/questions/21690445/as3-help-for-commas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!