I see Jester already beat me to it, but here's another potential 
solution:

<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";>
<!-- Declare a CurrencyFormatter and define parameters. -->
<mx:CurrencyFormatter id="Price" precision="2"
rounding="none"
decimalSeparatorTo="."
thousandsSeparatorTo=","
useThousandsSeparator="true"
useNegativeSign="true"
currencySymbol="$"
alignSymbol="left" />
<mx:Script>
<![CDATA[
import mx.formatters.CurrencyFormatter;

var todaysPrice=0.25;

function formatPrice(cf: CurrencyFormatter, n: Number) : String {
    var s: String = cf.format(n);
    return (s.charAt(1) != ".")? s : cf.currencySymbol + "0." + 
s.substr(2);
}
]]>
</mx:Script>

<!-- Trigger the formatter while populating a string with data. -->
<mx:TextInput text="Today's price is {formatPrice(Price, 
todaysPrice)}." />

</mx:Application>


--- In [email protected], "Doug Lowder" <[EMAIL PROTECTED]> 
wrote:
>
> ... and now I see that I missed the fact that you changed the 
> currency symbol in the posted code, which explains the difference.
> 
> --- In [email protected], "Doug Lowder" <douglowder@> 
> wrote:
> >
> > The exact output I get from the sample code is:
> >  "Today's price is $0.25."
> > 
> > There must be something else going on if you are getting 
different 
> > results, like no leading 0.
> > 
> > My configuration is:
> > Windows XP Pro
> > Flex 1.5 Build 87315.134646 Developer Edition
> > Tomcat 5.0.19 standalone server
> > 
> > 
> > --- In [email protected], Andriy Panas <dutchman@> 
wrote:
> > >
> > > Hello , flexcoders
> > > 
> > >   I was stumbled upon that all my fractional numbers like 
0.25, 
> > 0.45,
> > > 0.65, etc are displayed after formatting with 
> > <mx:CurrencyFormatter>
> > > like this:
> > > 
> > > $.25, $.45, $.65
> > > 
> > > What I want my numbers to be displayed is:
> > > 
> > > $0.25, $0.45, $.65.
> > > 
> > >   I cannot find a simple and reliable way to specify the MUST 
> > inclusion
> > > of 0 number when using standard <mx:CurrencyFormatter>. 
Playing 
> > with
> > > currencySymbol="$0" attribute is not a reliable solution, IMHO.
> > > 
> > > Should I resort to writing my own formatter?
> > > 
> > > 
> > > -----START of sample code copied from Flex 1.5 help section 
> > (http://tinyurl.com/jyckh) --
> > > 
> > > <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";>
> > > <!-- Declare a CurrencyFormatter and define parameters. -->
> > >    <mx:CurrencyFormatter id="Price" precision="2"
> > >       rounding="none"
> > >       decimalSeparatorTo="."
> > >       thousandsSeparatorTo=","
> > >       useThousandsSeparator="true"
> > >       useNegativeSign="true"
> > >       currencySymbol="$0"
> > >       alignSymbol="left" />
> > >    <mx:Script>
> > >       <![CDATA[
> > >          var todaysPrice=0.25;
> > >       ]]>
> > >    </mx:Script>
> > > 
> > >    <!-- Trigger the formatter while populating a string with 
> > data. -->
> > >    <mx:TextInput text="Today's price is {Price.format
> > (todaysPrice)}." /> 
> > > 
> > > </mx:Application>   
> > > 
> > > ---END of sample code copied from Flex 1.5 help section -------
--
> --
> > -------
> > > 
> > > -- 
> > > Best regards,
> > >  Andriy                          mailto:dutchman@
> > >
> >
>






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Check out the new improvements in Yahoo! Groups email.
http://us.click.yahoo.com/6pRQfA/fOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to