Adobe® Flash® Platform için ActionScript® 3.0 Başvurusu
Ana Sayfa  |  Paket ve Sınıf Listesini Gizle |  Paketler  |  Sınıflar  |  Yenilikler  |  Dizin  |  Ekler  |  Niçin İngilizce?
Filtreler: Sunucudan Veri Alınıyor...
Sunucudan Veri Alınıyor...
mx.formatters 

NumberFormatter  - AS3 Flex

Paketmx.formatters
Sınıfpublic class NumberFormatter
Miras AlmaNumberFormatter Inheritance Formatter Inheritance 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.NumberFormatter sınıfını kullanmanızı önerir.

The NumberFormatter class formats a valid number by adjusting the decimal rounding and precision, the thousands separator, and the negative sign.

If you use both the rounding and precision properties, rounding is applied first, and then you set the decimal length by using the specified precision value. This lets you round a number and still have a trailing decimal; for example, 303.99 = 304.00.

If an error occurs, an empty String is returned and a String describing 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 the format() method. The value should be a valid number in the form of a Number or a String.
  • "Invalid format" means one of the parameters contain an unusable setting.

MXML SözdizimiexpandedMXML Sözdizimini Gizle

The <mx:NumberFormatter> tag inherits all of the tag attributes of its superclass, and adds the following tag attributes:

  <mx:NumberFormatter
    decimalSeparatorFrom="."
    decimalSeparatorTo="."
    precision="-1"
    rounding="none|up|down|nearest"
    thousandsSeparatorFrom=","
    thousandsSeparatorTo=","
    useNegativeSign="true|false"
    useThousandsSeparator="true|false"/>  
  

Örnekleri görüntüle

İlgili API Öğeleri



Genel Özellikler
 ÖzellikTanımlayan:
 Inheritedconstructor : Object
Belirli bir nesne örneği için sınıf nesnesine veya yapıcı işlevine bir başvuru.
Object
  decimalSeparatorFrom : String
Decimal separator character to use when parsing an input String.
NumberFormatter
  decimalSeparatorTo : String
Decimal separator character to use when outputting formatted decimal numbers.
NumberFormatter
 Inheritederror : String
Description saved by the formatter when an error occurs.
Formatter
  precision : Object
Number of decimal places to include in the output String.
NumberFormatter
  rounding : String
Specifies how to round the number.
NumberFormatter
  thousandsSeparatorFrom : String
Character to use as the thousands separator in the input String.
NumberFormatter
  thousandsSeparatorTo : String
Character to use as the thousands separator in the output String.
NumberFormatter
  useNegativeSign : Object
If true, format a negative number by preceding it with a minus "-" sign.
NumberFormatter
  useThousandsSeparator : Object
If true, split the number into thousands increments by using a separator character.
NumberFormatter
Korunan Özellikler
 ÖzellikTanımlayan:
 InheritedresourceManager : IResourceManager
[salt okunur] A reference to the object which manages all of the application's localized resources.
Formatter
Genel Yöntemler
 YöntemTanımlayan:
  
Constructor.
NumberFormatter
  
[geçersiz kıl] Formats the number as a String.
NumberFormatter
 Inherited
Bir nesnenin belirli bir özelliğinin tanımlı olup olmadığını gösterir.
Object
 Inherited
Object sınıfının bir örneğinin parametre olarak belirtilen nesnenin prototip zincirinde olup olmadığını gösterir.
Object
 Inherited
Belirtilen özelliğin bulunup bulunmadığını ve numaralandırılabilir olup olmadığını gösterir.
Object
 Inherited
Dinamik bir özelliğin döngü işlemlerinde kullanılabilirliğini ayarlar.
Object
 Inherited
Bu nesnenin, yerel ayara özel kurallara göre biçimlendirilmiş dize temsilini döndürür.
Object
 Inherited
Belirtilen nesnenin dize olarak temsil edilen halini döndürür.
Object
 Inherited
Belirtilen nesnenin temel değerini döndürür.
Object
Korunan Yöntemler
 YöntemTanımlayan:
 Inherited
This method is called when a Formatter is constructed, and again whenever the ResourceManager dispatches a "change" Event to indicate that the localized resources have changed in some way.
Formatter
Özellik Ayrıntısı

decimalSeparatorFrom

ö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.

When setting this property, ensure that the value of the thousandsSeparatorFrom property does not equal this property. Otherwise, an error occurs when formatting the value.

Varsayılan değer şudur ".".



Uygulama
    public function get decimalSeparatorFrom():String
    public function set decimalSeparatorFrom(value:String):void

İlgili API Öğeleri

decimalSeparatorTo

ö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.

When setting this property, ensure that the value of the thousandsSeparatorTo property does not equal this property. Otherwise, an error occurs when formatting the value.

Varsayılan değer şudur ".".



Uygulama
    public function get decimalSeparatorTo():String
    public function set decimalSeparatorTo(value:String):void

İlgili API Öğeleri

precision

ö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 a value of 1.453. If precision is -1 and you have 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):void

rounding

ö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

Specifies how to round the number.

In ActionScript, you can use the following constants to set this property: NumberBaseRoundType.NONE, NumberBaseRoundType.UP, NumberBaseRoundType.DOWN, or NumberBaseRoundType.NEAREST. Valid MXML values are "down", "nearest", "up", and "none".

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.

When setting this property, ensure that the value of the decimalSeparatorFrom property does not equal this property. Otherwise, an error occurs when formatting the value.

Varsayılan değer şudur ",".



Uygulama
    public function get thousandsSeparatorFrom():String
    public function set thousandsSeparatorFrom(value:String):void

İlgili API Öğeleri

thousandsSeparatorTo

ö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.

When setting this property, ensure that the value of the decimalSeparatorTo property does not equal this property. Otherwise, an error occurs when formatting the value.

Varsayılan değer şudur ",".



Uygulama
    public function get thousandsSeparatorTo():String
    public function set thousandsSeparatorTo(value:String):void

İlgili API Öğeleri

useNegativeSign

ö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):void

useThousandsSeparator

ö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):void
Yapıcı Ayrıntı

NumberFormatter

()Yapıcı
public function NumberFormatter()

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.

Yöntem Ayrıntısı

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 the number as a String. 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.

Döndürür
String — Formatted String. Empty if an error occurs.
NumberFormatterExample.mxml
<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate NumberFormatter. -->
<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) {
                    formattedNumber.text = numberFormatter.format(inputVal.text);
                } else {
                    formattedNumber.text = "";
                }
            }
        ]]>
    </fx:Script>

    <fx:Declarations>
        <mx:NumberFormatter id="numberFormatter" precision="4" 
                useThousandsSeparator="true" useNegativeSign="true"/>

        <mx:NumberValidator id="numVal" source="{inputVal}" property="text" 
                allowNegative="true" domain="real"/>
    </fx:Declarations>

    <s:Panel title="NumberFormatter Example"
            width="75%" height="75%"
            horizontalCenter="0" verticalCenter="0">
        <mx:Form left="10" right="10" top="10" bottom="10">
            <mx:FormItem label="Enter number:">
                <s:TextInput id="inputVal" text="" width="50%"/>
            </mx:FormItem>
            <mx:FormItem label="Formatted number (precision=4): ">
                <s:TextInput id="formattedNumber" editable="false" width="50%"/>
            </mx:FormItem>
            <mx:FormItem>
                <s:Button label="Validate and Format" click="Format();"/>
            </mx:FormItem>
        </mx:Form>
    </s:Panel>

</s:Application>




[ X ]Niçin İngilizce?
ActionScript 3.0 Başvurusu'ndaki içerik İngilizce görünür

ActionScript 3.0 Başvurusu'nun tüm bölümleri tüm dillere çevrilmemiştir. Bir dil öğesi çevrilmediğinde İngilizce görünür. Örneğin, ga.controls.HelpBox sınıfı hiçbir dile çevrilmez. Bu nedenle, başvurunun Türkçe versiyonunda ga.controls.HelpBox sınıfı İngilizce görünür.