Flex Spark 货币格式化程序格式 '0'不正确地
我在使用 Spark CurrencyFormatter
时遇到了问题,它无法正确格式化值 0
。
所有其他值的格式都很好。
我使用的是 Flex 4.5
下面是一个示例:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Declarations>
<s:CurrencyFormatter currencyISOCode="GBP" id="formatter" useCurrencySymbol="true" currencySymbol="£" trailingZeros="true" leadingZero="true" negativeCurrencyFormat="0" positiveCurrencyFormat="0" />
</fx:Declarations>
<s:HGroup>
<s:TextInput id="textInput" />
<s:Label text="{formatter.format(textInput.text)}" />
</s:HGroup>
</s:Application>
当 textInput
的值不是 0 时,它的格式正确。
使其正确格式化的正确设置是什么?
I'm having trouble with a spark CurrencyFormatter
, which is failing to format the value 0
correctly.
All other values are formatted fine.
I'm using Flex 4.5
Here's an example:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Declarations>
<s:CurrencyFormatter currencyISOCode="GBP" id="formatter" useCurrencySymbol="true" currencySymbol="£" trailingZeros="true" leadingZero="true" negativeCurrencyFormat="0" positiveCurrencyFormat="0" />
</fx:Declarations>
<s:HGroup>
<s:TextInput id="textInput" />
<s:Label text="{formatter.format(textInput.text)}" />
</s:HGroup>
</s:Application>
When the value of the textInput
is anything other than 0, it's formatted correctly.
What's the correct setting to get this to format correctly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也注意到了这一点。我从 Adobe 的帮助 稍作调整后,我发现如果我通过了 0.001,我会得到“$0.00”作为回报。这一定是一个错误,否则它就很愚蠢。另外,货币格式化程序的 mx 形式似乎没有这个问题。同时,我将查找“0”并将“.001”添加到程序中的值中。希望有人能给出更好的答案。
I noticed this also. I downloaded example2 from Adobe's help and after tweaking it a bit, I found that if I passed it 0.001, I got "$0.00" in return. This has got to be a bug, otherwise it's just silly. Also, the mx form of the currencyformatter doesn't seem to have this problem. For the meantime, I'm going to be looking for "0" and adding ".001" to the value in my program. Hopefully someone comes up with a better answer.
我知道这是一个旧线程,但我会回答未来的疑问。
您可以通过将值
UP
设置为mx:CurrencyFormatter
的属性rounding
来解决此问题。下面是一个示例:
然后在您的代码中,当您格式化值 0.001 或 0.00000001 时,您会得到“0,01”结果。
I know this is an old thread, but I am gonna answer for future doubts.
You can solve this problem by setting the value
UP
to the propertyrounding
of themx:CurrencyFormatter
.Here is an example:
Then in your code, when you format a value 0.001 or 0.00000001, you get "0,01" as a result.