I need to write a method doing a formatting of numeric value given a pattern as one of the parameter, in actionscript.
For example:
a. 12345.00 using format pattern ###,###.## resulting 12,345.00
b. 12345.00 using format pattern ##,##,##.## resulting 1,23,45.00
Initially, I thought that NumberFormatter able to do that, but after reading documentation, it seems you are not able to accept pattern.
Any idea how to implement this ? I’m using Flex 4.1
UPDATE: I made an advanced formatter based on the sample created by Jason. You can download it here : link
UPDATE:
After a bit more thought on this custom formatter class, I’ve decided to update it a bit. You can see the updated CustomPatternFormatter class here.
The updated class adds:
I hope this helps!
Original answer:
You’ll have to create custom Formatter to handle this. Here’s something I threw together real fast. You may have to adjust it to fit your situation.
CustomNumericFormatter.as