What I am doing is a bit different. I need to change a currency type on the
fly. Let's say I have a value shown like this:
$1000. I need to change it to 1000 €. I thought the following code would
work:
 var cf:CurrencyFormatter = new CurrencyFormatter();
var numericValue = cf.parse("$1000");
it does return a numeric value of the currency when a currency symbol in
the front, but parsing Euro that way returns NaN.



On Sun, Jul 13, 2014 at 12:09 PM, Deepak MS <[email protected]>
wrote:

> I tried it with euro and which gets placed at the end of the value. It
> worked fine like earlier example
>
>    var value:int = 893829;
>                 var cf:CurrencyFormatter = new CurrencyFormatter();
>                 cf.currencySymbol = '€';
>                 cf.positiveCurrencyFormat = 3;
>
>                 cf.useCurrencySymbol = true;
>                 var s:String = cf.format(value); // s =  893,829.00 €
>                 var cfr:CurrencyParseResult = cf.parse(s);
> //cfr.currencyString     = "€"  ,     cfr.value     = 893829
>
> or share your code which you trying and we'll see where it is going wrong.
>
>
> On Sun, Jul 13, 2014 at 8:57 PM, mark goldin <[email protected]>
> wrote:
>
> > Try any currency (Euro) which has a currency symbol at the end of the
> > value.
> >
> >
> > On Sun, Jul 13, 2014 at 9:28 AM, Deepak MS <[email protected]>
> > wrote:
> >
> > > I believe currency string here you meant was using currencyformatter?
> > >
> > >                 var value:int = 893829;
> > >                 var cf:CurrencyFormatter = new CurrencyFormatter();
> > > //import spark.formatters.CurrencyFormatter;
> > >                 cf.currencySymbol = '$';
> > >                 cf.useCurrencySymbol = true;
> > >                 var s:String = cf.format(value); // s =  $893,829.00
> > >                 var cfr:CurrencyParseResult = cf.parse(s);
> > > //cfr.currencyString     = "$"  ,     cfr.value     = 893829
> > >
> > > "but it only works well with currencies which have a
> > > currency symbol in the front."
> > > - I'm not clear on this. Currency formatting would be used with
> currency
> > > symbol. If you dont need currency symbol, you can go for
> NumberFormatter,
> > > which has parseNumber method.
> > >
> > >
> > > On Sun, Jul 13, 2014 at 2:24 AM, mark goldin <[email protected]>
> > > wrote:
> > >
> > > > Is there a reliable way of extracting a value from a currency string?
> > > > I am using parse, but it only works well with currencies which have a
> > > > currency symbol in the front.
> > > >
> > > > Thanks
> > > >
> > >
> >
>

Reply via email to