User Guide
272 Chapter 14: Data Integration (Flash Professional Only)
6.
Next, set the DataGrid index default value to 0 to make it available for data binding: select the
menu_dg instance, click the Schema tab, select selectedIndex:number, and in the Default
Value field in the lower pane, type
0.
7.
Save and test the application. Click Load Data, then click different items in the data grid. The
text area updates with the detailed description for each food item. Each time the user selects a
new item in the data grid, the index of the array is updated to show the data associated with the
new item.
Note: The index for property appears only in the Binding attributes pane for a schema item that
is the field of an object within an array.
Sometimes you might need to manually define a schema that identifies a schema item as a field of
an object contained within an array. In the following example, the id, billable, rate, and duration
schema fields are all considered attributes of an object contained within the row array:
results : XML
datapacket : Object
row : Array
[n] : object
@id : Integer
@billable : Boolean
@rate : Number
@duration : Integer
If a binding is created for any of these items, an index for 'row' property appears in the
Binding Attributes pane, so that an index can be specified for the row array. Flash uses the [n]
schema field to identify this type of relationship. Therefore, you might need to duplicate this
entry if you are manually creating a schema. To do this, you add a new schema field under the
row : Array node and set Field Name for the schema field to [n]. The compiler reads this value
and creates an
index for property if it is used within a binding.
About debugging data binding and web services (Flash Professional only)
Data binding is a series of actions that occur in response to events, such as the following:
• The data of a component property changes.
• A web service call is completed.
• An XML document is fetched.
You can create a log of all actions that are performed by data binding or web services. To create
the log, create a new Log object by adding the following code to the first frame in your Flash
document:
_global.__dataLogger=new mx.data.binding.Log(); //to enable trace log
To turn the trace log off, use the following code:
_global.__dataLogger=null; //disable trace for binding.