Hi all,
I want to format a number in indian format.
for example,
x= 123456 should be formatted as 1,23,456.
How can i do it in flex?
Thanks,
Hi all,
I want to format a number in indian format.
for example,
x= 123456 should be formatted as 1,23,456.
How can i do it in flex?
Thanks,
Use the numberformatter.
<mx:NumberFormatter id="myFormatter"
decimalSeparatorFrom="."
decimalSeparatorTo="."
precision="-1"
rounding="none"
thousandsSeparatorFrom=","
thousandsSeparatorTo=","
useNegativeSign="true"
useThousandsSeparator="true"/>
actionscript code
x = myFormatter.format(x);
from http://livedocs.adobe.com/flex/2/langref/mx/formatters/NumberFormatter.html
Package mx.formatters Class public class NumberFormatter Inheritance NumberFormatter Inheritance Formatter Inheritance Object
The NumberFormatter class formats a valid number by adjusting the decimal rounding and precision, the thousands separator, and the negative sign.
If you use both the rounding and precision properties, rounding is applied first, and then you set the decimal length by using the specified precision value. This lets you round a number and still have a trailing decimal; for example, 303.99 = 304.00.
If an error occurs, an empty String is returned and a String describing the error is saved to the error property. The error property can have one of the following values:
MXML Syntaxcollapsed Show MXML Syntax expanded Hide MXML Syntax
The tag inherits all of the tag attributes of its superclass, and adds the following tag attributes:
<mx:NumberFormatter
decimalSeparatorFrom="."
decimalSeparatorTo="."
precision="-1"
rounding="none|up|down|nearest"
thousandsSeparatorFrom=","
thousandsSeparatorTo=","
useNegativeSign="true|false"
useThousandsSeparator="true|false"/>