User Guide
32 Chapter 2: Creating an Application with Components (Flash Professional Only)
Specify a schema for the XML data source
When you connect to an external XML data source with the XMLConnector component, you
need to specify a schema—a schematic representation which identifies the structure of the XML
document. The schema tells the XMLConnector component how to read the XML data source.
The easiest way to specify a schema is to import a copy of the XML file that you’re going to
connect to, and use that copy as a schema.
1.
Launch your web browser and go to www.flash-mx.com/mm/firstapp/problems.xml (the
location you set for the XMLConnector URL parameter).
2.
Select File > Save As.
3.
Save products.xml to the same location as the FLA file that you’re working on.
4.
Select Frame 1 in the main Timeline.
5.
On the Stage, select the products_xmlcon (XMLConnector) instance.
6.
In the Component inspector, click the Schema tab. Click the Import button (on the right side
of the Schema tab, above the scroll pane). In the Open dialog box, locate the products.xml file
that you imported in step 3, and click Open. The schema for the products.xml file appears in
the scroll pane of the Schema tab.
Bind the XMLConnector, DataSet, and DataGrid components
You’ll use the Binding tab in the Component inspector to bind the XMLConnector, DataSet, and
DataGrid component instances to one another.
For information on working with data binding, see “Data binding (Flash Professional only)” in
Using Flash.
1.
With the products_xmlcon (XMLConnector) instance selected on the Stage, click the Bindings
tab in the Component inspector.
2.
Click the Add Binding button.
3.
In the Add Binding dialog box, select the results.products.product array item and click
OK.
4.
In the Bindings tab, click the Bound To item in the Binding Attributes pane (the bottom pane,
showing attribute name-value pairs).
5.
In the Value column for the Bound To item, click the magnifying glass icon to open the Bound
To dialog box.
6.
In the Bound To dialog box, select the products_ds (DataSet) instance in the Component Path
pane. Select
dataProvider:array in the Schema Location pane. Click OK.
7.
In the Bindings tab, click the Direction item in the Binding Attributes pane. From the pop-up
menu in the Value column, select Out.
This option means that the data will pass from the products_xmlcon instance to the
products_ds instance (rather than passing in both directions, or passing from the DataSet
instance to the XMLConnector instance).