-
Dynamic text numbers, add comma
Need to add commas for formatting numbers to a dynamic text field. For example, 11000 should read 11,000.
Anyone have a quick script that would take care of this?
thanks
-
Well, after some trial and error I got it to work.
This won't work for numbers greater than xxx,xxx but works in this case.
textnumber = 1242;
textnumber = textnumber.toString();
textnumber = (textnumber.slice(-5,-3))+","+(textnumber.slice(-3));
-
var money = 999999999;
money = money.toString();
money = (money.slice(-9,-6))+","+(money.slice(-6,-3))+","+(money.slice(-3));
This works all u have to do is keep adding on to the code, say you want to go into the billions, you would need to add " (money.slice(-12,-9))+","+ " in front of the equal sign.
So if your variable was 100239100293 it would show up 100,239,100,293 instead of 100239,100,293 with the previous code.
-
I tried this and when I run a trace on value for my dynamic field I see the comma but I get NaN in my Dynamic Text Display
-
Senior Member
huh?
what is 'value'?
what is your code? you havent given us anything to work with?
var money = 999999999;
money = money.toString();
money = (money.slice(-9,-6))+","+(money.slice(-6,-3))+","+(money.slice(-3));
trace("MONEY: "+money);
someTextField_txt.text = money;
seems to work fine for me
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|