Monday, July 23, 2007

flex Data models

Data models
A data model is an object you can use to temporarily store data in memory so that it can be easily manipulated. You can define a data model in ActionScript, in MXML using a tag such as , or any object that contains properties. As an example, the following data model shows information such as a person's name, age, and phone number:

<mx:Model id="Employee">

<
name>
<
first>Jennifer</first>
<
last>Nadeau</last>
</
name>

<
age>30</age>
<
work_tel>555-555-5555</work_tel>
</
mx:Model>



The fields of a data model can contain static data (as in the example), or you can use data binding to pass data to and from the data model.

You can also define the data model within an XML file. You then reference the XML file through the file system or through a URL using the
<mx:Model> 


tag's source property, as the following example shows:
<mx:Model source="content.xml" id="Contacts"/>

<
mx:Model source="http://www.somesite.com/companyinfo.xml" id="myCompany"/>

No comments: