User Guide

294 Chapter 14: Data Integration (Flash Professional Only)
Schema kinds
A kind determines how a schema item for your component should be accessed at runtime. The
following kinds come with Flash MX Professional 2004:
None The default kind. This kind is identical to the Data kind.
Data The schema item is a data structure, and the data field is stored within the data structure
as specified by the field’s schema location. This is the normal case. The data structure can be in
either ActionScript or XML form.
Calculated This kind is used with the DataSet component. You can use it to define a calculated
field (a virtual field whose value is calculated at runtime, based on the values of other fields). You
write an event handler in ActionScript code that is invoked by the
DataSet.calcFields event
when any non-calculated field in a data sets current data record changes. The event handler must
set the value of the calculated fields in that record. There is no special processing when getting or
setting the value of a calculated field. For example, in the DataSet component you might define
three fields, called
price, quantity, and totalPrice. You would set the kind property for
totalPrice to Calculated so that you can assign it a value at runtime, as shown in the
following example:
function calculatedFunct(evt) {
evt.target.totalPrice = (evt.target.price * evt.target.quantity);
}
ds.addEventListener('calcFields', calculatedFunct);
}
See the DataSet.calcFields event in Using Components.
AutoTrigger This kind can be applied to any property of any component but is mainly useful
for connector component properties. When a new value is assigned to the property through data
binding, the trigger method of the component is called. For more information, see
WebServiceConnector.trigger() and XMLConnector.trigger() in Using Components.
You can create custom kinds. The number of kinds allowed is unlimited. Kinds are defined by
XML files found in the Flash MX Professional 2004 Configuration/Kinds folder. The definition
includes the following metadata:
An ActionScript class that will be instantiated to mediate access to the data
A Kind Options dialog box
Schema encoders
An encoder determines how a schema item for your component should be encoded/decoded at
runtime. Sometimes you might want a component property to have a different data type that
what is actually stored inside the component. For example, an XMLConnector component results
property is stored as an XML document, which contains only strings. You might want a certain
field in the results to appear as a Boolean value instead.