本文介绍了AS3帮助有关逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个code,我想在我的数字逗号。该中奖€169.85,但它在游戏中显示为 16985 00 。如何解决这个问题?

 公共职能jackpotstring():字符串{
    VAR myPattern:正则表达式= /./;
    VAR JP:数=中奖* DENOM;
    变种S:字符串= jp.toFixed(2)+;
    返回s.replace(/ [^ A-ZA-Z0-9 \ -_:] + /克,'');
}
 

解决方案

OU可以尝试像;

  VAR JP:数=中奖* DENOM;
JP = Math.round(JP * 100)/ 100; //值应该是这样的1698500
JP = JP / 10000; //值应该是类似169.85现
变种S:字符串=字符串(JP);
返回S;
 

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, ' ');
}
解决方案

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;

这篇关于AS3帮助有关逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 19:02