| Pacchetto | mx.formatters |
| Classe | public class Formatter |
| Ereditarietà | Formatter Object |
| Implementa | IFormatter |
| Sottoclassi | CurrencyFormatter, DateFormatter, NumberFormatter, PhoneFormatter, ZipCodeFormatter |
| Versione linguaggio: | ActionScript 3.0 |
| Versione prodotto: | Flex 3 |
| Versioni runtime: | Flash Player 9, AIR 1.1 |
format() method.
Sintassi MXML
Nascondi sintassi MXMLThe Formatter class defines the following tag attributes, which all of its subclasses inherit:
<mx:tagname
Properties
error=""
/>
Altri esempi
| Proprietà | Definito da | ||
|---|---|---|---|
![]() | constructor : Object
Un riferimento all'oggetto classe o alla funzione di costruzione per una determinata istanza di oggetto. | Object | |
| defaultInvalidFormatError : String [statico]
Error message for an invalid format string specified to the formatter. | Formatter | ||
| defaultInvalidValueError : String [statico]
Error messages for an invalid value specified to the formatter. | Formatter | ||
| error : String
Description saved by the formatter when an error occurs. | Formatter | ||
| Proprietà | Definito da | ||
|---|---|---|---|
| resourceManager : IResourceManager [sola lettura]
A reference to the object which manages
all of the application's localized resources. | Formatter | ||
| Metodo | Definito da | ||
|---|---|---|---|
Constructor. | Formatter | ||
Formats a value and returns a String
containing the new, formatted, value. | Formatter | ||
![]() |
Indica se per un oggetto è definita una proprietà specifica. | Object | |
![]() |
Indica se un'istanza della classe Object si trova nella catena di prototipi dell'oggetto specificato come parametro. | Object | |
![]() |
Indica se la proprietà specificata esiste ed è enumerabile. | Object | |
![]() |
Imposta la disponibilità di una proprietà dinamica per le operazioni cicliche. | Object | |
![]() |
Restituisce la rappresentazione in formato stringa di questo oggetto, formattato in base alle convenzioni specifiche per le versioni localizzate. | Object | |
![]() |
Restituisce la rappresentazione in formato stringa dell'oggetto specificato. | Object | |
![]() |
Restituisce il valore di base dell'oggetto specificato. | Object | |
| Metodo | Definito da | ||
|---|---|---|---|
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 | proprietà |
defaultInvalidFormatError:String| Versione linguaggio: | ActionScript 3.0 |
| Versione prodotto: | Flex 3 |
| Versioni runtime: | Flash Player 9, AIR 1.1 |
Error message for an invalid format string specified to the formatter.
Il valore predefinito è "Invalid format".
Implementazione
public static function get defaultInvalidFormatError():String public static function set defaultInvalidFormatError(value:String):voiddefaultInvalidValueError | proprietà |
defaultInvalidValueError:String| Versione linguaggio: | ActionScript 3.0 |
| Versione prodotto: | Flex 3 |
| Versioni runtime: | Flash Player 9, AIR 1.1 |
Error messages for an invalid value specified to the formatter.
Il valore predefinito è "Invalid value".
Implementazione
public static function get defaultInvalidValueError():String public static function set defaultInvalidValueError(value:String):voiderror | proprietà |
public var error:String| Versione linguaggio: | ActionScript 3.0 |
| Versione prodotto: | Flex 3 |
| Versioni runtime: | 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 | proprietà |
resourceManager:IResourceManager [sola lettura] | Versione linguaggio: | ActionScript 3.0 |
| Versione prodotto: | Flex 3 |
| Versioni runtime: | 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.
Questa proprietà può essere utilizzata come origine per l’associazione di dati. Quando questa proprietà viene modificata, invia l’evento unused .
Implementazione
protected function get resourceManager():IResourceManagerFormatter | () | Funzione di costruzione |
public function Formatter()| Versione linguaggio: | ActionScript 3.0 |
| Versione prodotto: | Flex 3 |
| Versioni runtime: | Flash Player 9, AIR 1.1 |
Constructor.
format | () | metodo |
public function format(value:Object):String| Versione linguaggio: | ActionScript 3.0 |
| Versione prodotto: | Flex 3 |
| Versioni runtime: | 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.
Parametri
value:Object — Value to be formatted.
|
String — The formatted string.
|
resourcesChanged | () | metodo |
protected function resourcesChanged():void| Versione linguaggio: | ActionScript 3.0 |
| Versione prodotto: | Flex 3 |
| Versioni runtime: | 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, 02:44 PM Z
Mostra sintassi MXML