| Paket | mx.formatters |
| Sınıf | public class CurrencyFormatter |
| Miras Alma | CurrencyFormatter Formatter Object |
| Dil Sürümü: | ActionScript 3.0 |
| Ürün Sürümü: | Flex 3 |
| Çalışma Zamanı Sürümleri: | Flash Player 9, AIR 1.1 |
![]() | Flex 4.5 sürümünden itibaren, Adobe bu sınıfa alternatif olarak spark.formatters.CurrencyFormatter sınıfını kullanmanızı önerir. |
The CurrencyFormatter class formats a valid number as a currency value. It adjusts the decimal rounding and precision, the thousands separator, and the negative sign; it also adds a currency symbol. You place the currency symbol on either the left or the right side of the value with the
alignSymbol property.
The currency symbol can contain multiple characters,
including blank spaces.
If an error occurs, an empty String is returned and a String that describes
the error is saved to the error property. The error
property can have one of the following values:
-
"Invalid value"means an invalid numeric value is passed to theformat()method. The value should be a valid number in the form of a Number or a String. -
"Invalid format"means one of the parameters contains an unusable setting.
MXML Sözdizimini GizleThe <mx:CurrencyFormatter> tag
inherits all of the tag attributes of its superclass,
and adds the following tag attributes:
<mx:CurrencyFormatter
alignSymbol="left|right"
currencySymbol="$"
decimalSeparatorFrom="."
decimalSeparatorTo="."
precision="-1"
rounding="none|up|down|nearest"
thousandsSeparatorFrom=","
thousandsSeparatorTo=","
useNegativeSign="true|false"
useThousandsSeparator="true|false"
/>
İlgili API Öğeleri
| Özellik | Tanımlayan: | ||
|---|---|---|---|
| alignSymbol : String
Aligns currency symbol to the left side or the right side
of the formatted number. | CurrencyFormatter | ||
![]() | constructor : Object
Belirli bir nesne örneği için sınıf nesnesine veya yapıcı işlevine bir başvuru. | Object | |
| currencySymbol : String
Character to use as a currency symbol for a formatted number. | CurrencyFormatter | ||
| decimalSeparatorFrom : String
Decimal separator character to use
when parsing an input string. | CurrencyFormatter | ||
| decimalSeparatorTo : String
Decimal separator character to use
when outputting formatted decimal numbers. | CurrencyFormatter | ||
![]() | error : String
Description saved by the formatter when an error occurs. | Formatter | |
| precision : Object
Number of decimal places to include in the output String. | CurrencyFormatter | ||
| rounding : String
How to round the number. | CurrencyFormatter | ||
| thousandsSeparatorFrom : String
Character to use as the thousands separator
in the input String. | CurrencyFormatter | ||
| thousandsSeparatorTo : String
Character to use as the thousands separator
in the output string. | CurrencyFormatter | ||
| useNegativeSign : Object
If true, format a negative number
by preceding it with a minus "-" sign. | CurrencyFormatter | ||
| useThousandsSeparator : Object
If true, split the number into thousands increments
by using a separator character. | CurrencyFormatter | ||
| Yöntem | Tanımlayan: | ||
|---|---|---|---|
Constructor. | CurrencyFormatter | ||
[geçersiz kıl]
Formats value as currency. | CurrencyFormatter | ||
![]() |
Bir nesnenin belirli bir özelliğinin tanımlı olup olmadığını gösterir. | Object | |
![]() |
Object sınıfının bir örneğinin parametre olarak belirtilen nesnenin prototip zincirinde olup olmadığını gösterir. | Object | |
![]() |
Belirtilen özelliğin bulunup bulunmadığını ve numaralandırılabilir olup olmadığını gösterir. | Object | |
![]() |
Dinamik bir özelliğin döngü işlemlerinde kullanılabilirliğini ayarlar. | Object | |
![]() |
Bu nesnenin, yerel ayara özel kurallara göre biçimlendirilmiş dize temsilini döndürür. | Object | |
![]() |
Belirtilen nesnenin dize olarak temsil edilen halini döndürür. | Object | |
![]() |
Belirtilen nesnenin temel değerini döndürür. | Object | |
alignSymbol | özellik |
alignSymbol:String| Dil Sürümü: | ActionScript 3.0 |
| Ürün Sürümü: | Flex 3 |
| Çalışma Zamanı Sürümleri: | Flash Player 9, AIR 1.1 |
Aligns currency symbol to the left side or the right side
of the formatted number.
Permitted values are "left" and "right".
Varsayılan değer şudur "left".
Uygulama
public function get alignSymbol():String public function set alignSymbol(value:String):voidcurrencySymbol | özellik |
currencySymbol:String| Dil Sürümü: | ActionScript 3.0 |
| Ürün Sürümü: | Flex 3 |
| Çalışma Zamanı Sürümleri: | Flash Player 9, AIR 1.1 |
Character to use as a currency symbol for a formatted number. You can use one or more characters to represent the currency symbol; for example, "$" or "YEN". You can also use empty spaces to add space between the currency character and the formatted number. When the number is a negative value, the currency symbol appears between the number and the minus sign or parentheses.
Varsayılan değer şudur "$".
Uygulama
public function get currencySymbol():String public function set currencySymbol(value:String):voiddecimalSeparatorFrom | özellik |
decimalSeparatorFrom:String| Dil Sürümü: | ActionScript 3.0 |
| Ürün Sürümü: | Flex 3 |
| Çalışma Zamanı Sürümleri: | Flash Player 9, AIR 1.1 |
Decimal separator character to use when parsing an input string.
Varsayılan değer şudur ".".
Uygulama
public function get decimalSeparatorFrom():String public function set decimalSeparatorFrom(value:String):voiddecimalSeparatorTo | özellik |
decimalSeparatorTo:String| Dil Sürümü: | ActionScript 3.0 |
| Ürün Sürümü: | Flex 3 |
| Çalışma Zamanı Sürümleri: | Flash Player 9, AIR 1.1 |
Decimal separator character to use when outputting formatted decimal numbers.
Varsayılan değer şudur ".".
Uygulama
public function get decimalSeparatorTo():String public function set decimalSeparatorTo(value:String):voidprecision | özellik |
precision:Object| Dil Sürümü: | ActionScript 3.0 |
| Ürün Sürümü: | Flex 3 |
| Çalışma Zamanı Sürümleri: | Flash Player 9, AIR 1.1 |
Number of decimal places to include in the output String.
You can disable precision by setting it to -1.
A value of -1 means do not change the precision. For example,
if the input value is 1.453 and rounding
is set to NumberBaseRoundType.NONE, return 1.453.
If precision is -1 and you set some form of
rounding, return a value based on that rounding type.
Varsayılan değer şudur -1.
Uygulama
public function get precision():Object public function set precision(value:Object):voidrounding | özellik |
rounding:String| Dil Sürümü: | ActionScript 3.0 |
| Ürün Sürümü: | Flex 3 |
| Çalışma Zamanı Sürümleri: | Flash Player 9, AIR 1.1 |
How to round the number.
In ActionScript, the value can be NumberBaseRoundType.NONE,
NumberBaseRoundType.UP,
NumberBaseRoundType.DOWN, or NumberBaseRoundType.NEAREST.
In MXML, the value can be "none",
"up", "down", or "nearest".
Varsayılan değer şudur NumberBaseRoundType.NONE.
Uygulama
public function get rounding():String public function set rounding(value:String):voidİlgili API Öğeleri
thousandsSeparatorFrom | özellik |
thousandsSeparatorFrom:String| Dil Sürümü: | ActionScript 3.0 |
| Ürün Sürümü: | Flex 3 |
| Çalışma Zamanı Sürümleri: | Flash Player 9, AIR 1.1 |
Character to use as the thousands separator in the input String.
Varsayılan değer şudur ",".
Uygulama
public function get thousandsSeparatorFrom():String public function set thousandsSeparatorFrom(value:String):voidthousandsSeparatorTo | özellik |
thousandsSeparatorTo:String| Dil Sürümü: | ActionScript 3.0 |
| Ürün Sürümü: | Flex 3 |
| Çalışma Zamanı Sürümleri: | Flash Player 9, AIR 1.1 |
Character to use as the thousands separator in the output string.
Varsayılan değer şudur ",".
Uygulama
public function get thousandsSeparatorTo():String public function set thousandsSeparatorTo(value:String):voiduseNegativeSign | özellik |
useNegativeSign:Object| Dil Sürümü: | ActionScript 3.0 |
| Ürün Sürümü: | Flex 3 |
| Çalışma Zamanı Sürümleri: | Flash Player 9, AIR 1.1 |
If true, format a negative number
by preceding it with a minus "-" sign.
If false, format the number
surrounded by parentheses, for example (400).
Varsayılan değer şudur true.
Uygulama
public function get useNegativeSign():Object public function set useNegativeSign(value:Object):voiduseThousandsSeparator | özellik |
useThousandsSeparator:Object| Dil Sürümü: | ActionScript 3.0 |
| Ürün Sürümü: | Flex 3 |
| Çalışma Zamanı Sürümleri: | Flash Player 9, AIR 1.1 |
If true, split the number into thousands increments
by using a separator character.
Varsayılan değer şudur true.
Uygulama
public function get useThousandsSeparator():Object public function set useThousandsSeparator(value:Object):voidCurrencyFormatter | () | Yapıcı |
public function CurrencyFormatter()| Dil Sürümü: | ActionScript 3.0 |
| Ürün Sürümü: | Flex 3 |
| Çalışma Zamanı Sürümleri: | Flash Player 9, AIR 1.1 |
Constructor.
format | () | yöntem |
override public function format(value:Object):String| Dil Sürümü: | ActionScript 3.0 |
| Ürün Sürümü: | Flex 3 |
| Çalışma Zamanı Sürümleri: | Flash Player 9, AIR 1.1 |
Formats value as currency.
If value cannot be formatted, return an empty String
and write a description of the error to the error property.
Parametreler
value:Object — Value to format.
|
String — Formatted string. Empty if an error occurs.
|
<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate the CurrencyFormatter. -->
<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">
<fx:Script>
<![CDATA[
import mx.events.ValidationResultEvent;
private var vResult:ValidationResultEvent;
// Event handler to validate and format input.
private function Format():void {
vResult = numVal.validate();
if (vResult.type==ValidationResultEvent.VALID) {
var temp:Number = Number(priceUS.text);
formattedUSPrice.text = usdFormatter.format(temp);
} else {
formattedUSPrice.text = "";
}
}
]]>
</fx:Script>
<fx:Declarations>
<mx:CurrencyFormatter id="usdFormatter" precision="2"
currencySymbol="$" decimalSeparatorFrom="."
decimalSeparatorTo="." useNegativeSign="true"
useThousandsSeparator="true" alignSymbol="left"/>
<mx:NumberValidator id="numVal" source="{priceUS}" property="text"
allowNegative="true" domain="real"/>
</fx:Declarations>
<s:Panel title="CurrencyFormatter Example"
width="75%" height="75%"
horizontalCenter="0" verticalCenter="0">
<mx:Form left="10" right="10" top="10" bottom="10">
<mx:FormItem label="Enter U.S. dollar amount:">
<s:TextInput id="priceUS" text="" width="50%"/>
</mx:FormItem>
<mx:FormItem label="Formatted amount: ">
<s:TextInput id="formattedUSPrice" text="" width="50%" editable="false"/>
</mx:FormItem>
<mx:FormItem>
<s:Button label="Validate and Format" click="Format();"/>
</mx:FormItem>
</mx:Form>
</s:Panel>
</s:Application>
Tue Jun 12 2018, 01:09 PM Z

MXML Sözdizimini Göster