Found the offending function. A debug class used for doing CFDump like actions in ActionScript written back in 2003 overrwrote the String.prototype.toString method and formatted it to it's liking. Since the last line of NumberBase, a class CurrencyFormatter uses, goes:
return value.toString(); This causes the custom formatting function to run, thus mangling the intended return value. Not sure why yet, but the overrwriting doesn't occur when you run the SWF in debug mode in Flex Builder 1.5; maybe it locks String.prototype.toString from being overrwritten, or the library itself knows it's running in debug mode and doesn't run... :: shrugs ::. Either way, found the source of the bug. Thanks for your help! ----- Original Message ----- From: "Doug Lowder" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Thursday, March 23, 2006 6:48 PM Subject: [flexcoders] Re: Flex 1.5 CurrencyFormatter OK. Same results here with Firefox 1.5.0.1, Player 8.5 beta 2 (8,5,0,246), so something's fishy. --- In [email protected], "JesterXL" <[EMAIL PROTECTED]> wrote: > > Sorry, I'm still working on a true reproduceable test case. > > In my app, running in IE 6 Flash Player 7.0.22.0, Firefox 1.5 with Flash > Player 8.5 beta 2, and inside of Flex Builder running... all show $"0.00" > > However, running in Flex Builder in Debug mode shows it fine. > > I'm in the midst of creating a series of test cases and so far, everyone > works fine; I cannot duplicate the exact problem yet. My guess is, our app > utilizes a lot of other libraries written by f'ing nitwits screwing with > prototypes. As such, it's really hard to track down, but I don't give up > easily... thanks for your help G! > > ----- Original Message ----- > From: "Doug Lowder" <[EMAIL PROTECTED]> > To: <[email protected]> > Sent: Thursday, March 23, 2006 6:19 PM > Subject: [flexcoders] Re: Flex 1.5 CurrencyFormatter > > > Also works fine - $0.00. I hate it when that happens :/ > > Running Flash Player 8.0.22 here. Maybe something that was fixed in > a Flex update? > > --- In [email protected], "JesterXL" <jesterxl@> wrote: > > > > Try this: > > > > import mx.formatters.CurrencyFormatter; > > var result:String = USDformatter.format(0); > > trace(resutlt); > > > > > > ----- Original Message ----- > > From: "Doug Lowder" <douglowder@> > > To: <[email protected]> > > Sent: Thursday, March 23, 2006 5:55 PM > > Subject: [flexcoders] Re: Flex 1.5 CurrencyFormatter > > > > > > I couldn't reproduce it. Everything formats just fine with the > > grid's label function, even coming up blank with the "a" string as > > the price. > > > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"> > > > > <mx:Script> > > <![CDATA[ > > > > var data: Array = [{price: 0}, {price: 1.0}, {price: 2.00}, > > {price: 3.3}, {price: "a"}, {price: "0"} ]; > > function format1() > > { > > // test1_ti.text = USDformatter.format(test1_ti.text) > > test1_ti.text = formatPrice({price: test1_ti.text}, "none"); > > } > > > > function formatPrice( item : Object, columnName : > String ):String > > { > > var formattedPrice:String = USDformatter.format (item.price); > > return formattedPrice; > > } > > > > ]]> > > </mx:Script> > > > > <mx:CurrencyFormatter id="USDformatter" precision="2" > > currencySymbol="$" > > decimalSeparatorFrom="." > > decimalSeparatorTo="." useNegativeSign="true" > > useThousandsSeparator="true" alignSymbol="left"/> > > > > <mx:VBox width="100%" height="100%"> > > > > <mx:FormItem label="Currency Formatter:"> > > <mx:TextInput id="test1_ti" focusOut="format1()" enter="format1 > > ()" /> > > </mx:FormItem> > > <mx:DataGrid dataProvider="{data}"> > > <mx:columns> > > <mx:Array> > > <mx:DataGridColumn columnName="price" > headerText="Price" > > labelFunction="formatPrice" /> > > </mx:Array> > > </mx:columns> > > </mx:DataGrid> > > > > </mx:VBox> > > </mx:Application> > > > > > > --- In [email protected], "JesterXL" <jesterxl@> wrote: > > > > > > This works when used with a TextInput, but does not work with a > > > labelFunction with a DataGrid. I'm getting relaly weird results > > like > > > $"0.00" when you pass a 0 to the CurrencyFormatter.format > function. > > > > > > Why does this work perfectly with a TextField, but not with > > labelFunction > > > for a DataGrid? > > > > > > This works: > > > > > > <?xml version="1.0" encoding="utf-8"?> > > > <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"> > > > > > > <mx:Script> > > > <![CDATA[ > > > > > > import com.mindspacexi.utils.StrUtils; > > > > > > function format1() > > > { > > > test1_ti.text = USDformatter.format(test1_ti.text) > > > } > > > > > > > > > ]]> > > > </mx:Script> > > > > > > <mx:CurrencyFormatter id="USDformatter" precision="2" > > currencySymbol="$" > > > decimalSeparatorFrom="." > > > decimalSeparatorTo="." useNegativeSign="true" > > > useThousandsSeparator="true" alignSymbol="left"/> > > > > > > <mx:VBox width="100%" height="100%"> > > > > > > <mx:FormItem label="Currency Formatter:"> > > > <mx:TextInput id="test1_ti" focusOut="format1()" > enter="format1 > > ()" /> > > > </mx:FormItem> > > > > > > </mx:VBox> > > > </mx:Application> > > > > > > However, this psuedo code does not: > > > > > > function formatPrice( item : Object, columnName : String ):String > > > { > > > var formattedPrice:String = USDformatter.format(item.price); > > > return formattedPrice; > > > } > > > > > > I have confirmed through traces & debugs that item.price is in > > fact 0. > > > Strangely, even hardcoding 0 or "0" into the USDformatter.format > > function > > > still results in the $"0.00" problem. > > > > > > !?!? > > > > > > --JesterXL > > > > > > > > > > > > > > > > > > > -- > > 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 > > > > > > > > > -- > 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 > -- 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 -- 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/

