440 Data Integration (Flash Professional Only)
You can create custom encoders. The number of encoders allowed is unlimited. Encoders are
defined by XML files found in the Flash Professional 8 Configuration/Encoders folder. The
definition includes the following metadata:
■ An ActionScript class that will be instantiated to encode/decode the data. This class must
be a subclass of mx.databinding.DataAccessor.
■ An Encoder Options dialog box
Schema formatters
A formatter is an object that performs bidirectional conversion of data between a raw data
type and string data. The object has parameters that are settable during authoring and
runtime methods for performing the conversion. The following formatters come with Flash
Professional:
None The default formatter. No formatting is performed.
Boolean This formatter formats a Boolean value as a string. You can set up Boolean options
for strings that mean
true (for example, 1, yes) and strings that mean false (for example, 0,
no).
Compose String This formatter converts a data object to a string. You define the output
format using a string template. The template is arbitrary text that can refer to the data fields in
one of the following ways:
■ <field-name>
■ <field-name.field-name>, using dots to drill down into the data structure
■ <.>, which represents the entire object. This can be used, for example, when the original
object is a string, in which case
<.> is simply the value of the string.
Here are two examples using the Compose String formatter. A formatter could be applied to a
field that is an object with field name, quantity, and price, and the string output could read:
“You ordered <quantity> units of <name> at <$price> each.” In another example,
the formatter could be applied to a field that is a number, and you could define the string
output to read:
“You have <.> messages.”
Custom Formatter This formatter lets you specify a custom formatter by specifying a class
name. The formatter ActionScript class should have the following format:
class MyFormatter extends mx.data.binding.CustomFormatter {
// convert a raw value, returns a formatted value
function format(rawValue){
}
// convert a formatted value, returns a raw value
function unformat(formattedValue){
}
}