Paket | mx.formatters |
Klass | public class Formatter |
Arv | Formatter Object |
Implementerar | IFormatter |
Underklasser | CurrencyFormatter, DateFormatter, NumberFormatter, PhoneFormatter, ZipCodeFormatter |
Språkversion: | ActionScript 3.0 |
Produktversion: | Flex 3 |
Körningsmiljöversioner: | Flash Player 9, AIR 1.1 |
format()
method.
MXML-syntaxDölj MXML-syntaxThe Formatter class defines the following tag attributes, which all of its subclasses inherit:
<mx:tagname Properties error="" />
Fler exempel
Egenskap | Definieras med | ||
---|---|---|---|
constructor : Object
En referens till klassobjektet eller konstruktorfunktionen för en given objektinstans. | Object | ||
defaultInvalidFormatError : String [statisk]
Error message for an invalid format string specified to the formatter. | Formatter | ||
defaultInvalidValueError : String [statisk]
Error messages for an invalid value specified to the formatter. | Formatter | ||
error : String
Description saved by the formatter when an error occurs. | Formatter |
Egenskap | Definieras med | ||
---|---|---|---|
resourceManager : IResourceManager [skrivskyddad]
A reference to the object which manages
all of the application's localized resources. | Formatter |
Metod | Definieras med | ||
---|---|---|---|
Constructor. | Formatter | ||
Formats a value and returns a String
containing the new, formatted, value. | Formatter | ||
Anger om det finns en egenskap angiven för ett objekt. | Object | ||
Anger om en instans av klassen Object finns i prototypkedjan för objektet som anges som parameter. | Object | ||
Anger om den angivna egenskapen finns och är uppräkningsbar. | Object | ||
Anger tillgänglighet för en dynamisk egenskap för slingåtgärder. | Object | ||
Returnerar det här objektets strängrepresentation, formaterad i enlighet med språkspecifika konventioner. | Object | ||
Returnerar det angivna objektets strängbeteckning. | Object | ||
Returnerar det angivna objektets primitiva värde. | Object |
Metod | Definieras med | ||
---|---|---|---|
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 |
defaultInvalidFormatError | egenskap |
defaultInvalidFormatError:String
Språkversion: | ActionScript 3.0 |
Produktversion: | Flex 3 |
Körningsmiljöversioner: | Flash Player 9, AIR 1.1 |
Error message for an invalid format string specified to the formatter.
Standardvärdet är "Invalid format".
Implementering
public static function get defaultInvalidFormatError():String
public static function set defaultInvalidFormatError(value:String):void
defaultInvalidValueError | egenskap |
defaultInvalidValueError:String
Språkversion: | ActionScript 3.0 |
Produktversion: | Flex 3 |
Körningsmiljöversioner: | Flash Player 9, AIR 1.1 |
Error messages for an invalid value specified to the formatter.
Standardvärdet är "Invalid value".
Implementering
public static function get defaultInvalidValueError():String
public static function set defaultInvalidValueError(value:String):void
error | egenskap |
public var error:String
Språkversion: | ActionScript 3.0 |
Produktversion: | Flex 3 |
Körningsmiljöversioner: | Flash Player 9, AIR 1.1 |
Description saved by the formatter when an error occurs. For the possible values of this property, see the description of each formatter.
Subclasses must set this value
in the format()
method.
resourceManager | egenskap |
resourceManager:IResourceManager
[skrivskyddad] Språkversion: | ActionScript 3.0 |
Produktversion: | Flex 3 |
Körningsmiljöversioner: | Flash Player 9, AIR 1.1 |
A reference to the object which manages all of the application's localized resources. This is a singleton instance which implements the IResourceManager interface.
Den här egenskapen kan användas som källan för databindning. När den här egenskapen ändras, skickas händelsen unused
.
Implementering
protected function get resourceManager():IResourceManager
Formatter | () | Konstruktor |
public function Formatter()
Språkversion: | ActionScript 3.0 |
Produktversion: | Flex 3 |
Körningsmiljöversioner: | Flash Player 9, AIR 1.1 |
Constructor.
format | () | metod |
public function format(value:Object):String
Språkversion: | ActionScript 3.0 |
Produktversion: | Flex 3 |
Körningsmiljöversioner: | Flash Player 9, AIR 1.1 |
Formats a value and returns a String containing the new, formatted, value. All subclasses must override this method to implement the formatter.
Parametrar
value:Object — Value to be formatted.
|
String — The formatted string.
|
resourcesChanged | () | metod |
protected function resourcesChanged():void
Språkversion: | ActionScript 3.0 |
Produktversion: | Flex 3 |
Körningsmiljöversioner: | Flash Player 9, AIR 1.1 |
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.
This event will be dispatched when you set the ResourceManager's
localeChain
property, when a resource module
has finished loading, and when you call the ResourceManager's
update()
method.
Subclasses should override this method and, after calling
super.resourcesChanged()
, do whatever is appropriate
in response to having new resource values.
<?xml version="1.0" encoding="utf-8"?> <!-- Simple example to demonstrate the Formatter class. --> <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[ // Event handler to format the input. private function Format():void { // The format() method returns the formatted String, // or an empty String if there is an error. var formattedVal:String = numberFormatter.format(inputVal.text); if (formattedVal.length == 0) { // If there is an error, the Format.error property // contains the reason. formattedNumber.text = numberFormatter.error; } else { formattedNumber.text = formattedVal; } } ]]> </fx:Script> <fx:Declarations> <mx:NumberFormatter id="numberFormatter" /> </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 - a letter is invalid:"> <s:TextInput id="inputVal" text="" width="75%"/> </mx:FormItem> <mx:FormItem label="Formatted number: "> <s:TextInput id="formattedNumber" editable="false" width="75%"/> </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:40 PM Z