![]() | ![]() ![]() ![]() |
![]() | |
![]() | |
![]() |
An encoder determines how a schema item for your component should be encoded/decoded at runtime. The number of encoders allowed is unlimited, and you can create additional custom encoders/decoders. Encoders are defined by XML files found in the Flash MX Professional 2004 Configuration/Encoders folder. The definition includes the following metadata:
The following encoders ship with Flash MX Professional 2004:
None The default encoder. No encoding/decoding is performed.
Boolean Converts string data into Boolean ActionScript types. You must specify (via the Encoder Options property) one or more strings that will be interpreted as true
, and one or more strings that will be interpreted as false
. The settings are case-sensitive.
Date Converts string data into date ActionScript types. You must specify (via the Encoder Options property) a template string, which works as follows:
"YYYY"
, "MM"
, "DD"
, "HH"
, "NN"
, and/or "SS"
, mixed with any other combination of characters. DateToNumber Converts a Date object into its numeric equivalent. The DataSet component uses this encoder for fields that are of type Date. These values are stored within the DataSet component as numbers so that they can be sorted correctly.
Number Converts string data into number ActionScript types. There are no authoring settings for this encoder.
DatasetDeltaToXUpdateDelta This encoder is used in conjunction with the DataSet component. It extracts information from a DeltaPacket and generates XPath statements that are passed to the XUpdateResolver component to generate XUpdate statements. It gets the information that is needs to generate the XPath statements from two places:
rowNodeKey
property, which you must specify via the Encoder Options property (defined below).Using this information, the encoder can generate the correct XPath statements needed to identify your data within the XML file.
The encoder options contain one property:
rowNodeKey
property (String type). In order for an XML file to be updatable, the file must be structured in such a way that the node that represents a record in your data set can be uniquely identified with an XPath statement. This property combines an XPath statement with a field parameter to uniquely identify the row node within the XML file and the field within the data set that makes it unique.
In the following example, the row node represents a record within the XML file. The value of the id
attribute is what makes the row unique.
<datapacket> <row id="1" date="01/01/2003" rate="50" hours="5" /> <row id="2" date="02/04/2003" rate="50" hours="8" /> </datapacket>
The XPath to uniquely identify the row node would be as follows:
datapacket/row[@id='xxx']
Here, xxx represents a value for the id
attribute. In a typical case, the id
attribute in the XML file would be bound to the id
field of the DataSet component. Therefore, the rowNodeKey
value would be as follows:
datapacket/row[@id='?id']
The ?
identifies that this is a field parameter. The id
value specifies the name of the field in the data set. At runtime, the XUpdateResolver component substitutes the value from the id
field of the data set to generate the correct XPath for the record in question.
In the next example, the contacts node with a category attribute of "Management" represents the record(s) within the XML file, and the employeeId subnode contains the value that makes the record unique:
<datapacket>
<company id="5" name="ABC tech">
<contacts category="Mgmt">
<contact>
<empId>555</employeeId>
<name>Steve Woo</name>
<email>steve.woo@abctech.com</email>
</contact>
<contact>
<empId>382</employeeId>
<name>John Phillips</name>
<email>john.phillips@abctech.com</email>
</contact>
...
...
</contacts>
<contacts category="Executives">
...
...
</contacts>
...
...
</company>
</datapacket>
The rowNodeKey
value for this XML file would be as follows:
datapacket/company/contacts[@category='Mgmt']/contact
[empId='?empId']
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |