Flash CS3 Documentation |
|||
| ActionScript 2.0 Components Language Reference > Data binding classes > CustomFormatter class | |||
ActionScript Class Name mx.data.binding.CustomFormatter
The CustomFormatter class defines two methods, format() and unformat(), that provide the ability to transform data values from a specific data type to String, and vice versa. By default, these methods do nothing; you must implement them in a subclass of mx.data.binding. To make this class available at runtime, you must include the data binding classes in your FLA file. For more information, see Making data binding classes available at runtime.
|
NOTE |
|
The CustomFormatter class is supported only if you are working in a document that specifies ActionScript 2.0 in its Publish Settings. |
To create your own custom formatter, you first create a subclass of CustomFormatter that implements format() and unformat() methods. You can then assign that class to a binding between components either by creating a new Binding object with ActionScript (see Binding class), or by using the Bindings tab in the Component inspector.
You can also assign a formatter class to a component property on the Schema tab of the Component inspector. However, in that case, the formatter is used only when the data is needed in the form of a string. In contrast, formatters assigned with the Bindings panel, or created with ActionScript, are used whenever when the binding is executed.
For an example of writing and assigning a custom formatter using ActionScript, see Sample custom formatter.
For an overview of the classes in the mx.data.binding package, see Classes in the mx.data.binding package.
Flash CS3