Working with Flex data models
131
4.
Use the Data panel to inspect the data model.
You could also hand-code an
<mx:Model>
tag with a
source
property that specifies an XML file
or a URL that returns XML. The following are some examples:
<mx:Model source="content.xml" id="contact"/>
<mx:Model source="http://www.somesite.com/content.xml" id="company"/>
Note:
If you create a data model with the
source
property, you will be unable to visually create a
binding to the model because the binding destination is in an external file.
Binding a Flex data model to an object
After inserting a Flex data model in the MXML file, you can bind it to an object in the file.
You create one binding to retrieve data from a data model and a separate binding to pass data to a
data model. The procedures in this section describe how to create each type of binding.
This section covers the following topics:
•
“Retrieving data from a Flex data model” on page 131
•
“Passing data to a Flex data model” on page 134
Retrieving data from a Flex data model
You can create bindings that retrieve data from data models. For example, you can create a
binding that retrieves employee information from a data model so that you can display the
information in your MXML file.
To create a binding that retrieves data from a data model:
1.
Make sure your MXML file contains a component, data model, or data service that can accept
the data from the data model.
For example, your file can have a Label component that will display an employee name
received from the data model.
2.
In the Data panel, select the data model.
3.
In the Bindings panel (Window > Bindings), click the Plus (+) button.
The Add Binding - Step 1 dialog box appears.
Summary of Contents for FLEX BUILDER-USING FLEX BUILDER
Page 1: ...Using Flex Builder...
Page 116: ...116 Chapter 4 Building a Flex User Interface Visually...
Page 144: ...144 Chapter 6 Working with Data...
Page 154: ...154 Appendix A Basic Flex Concepts...