A data model is an object you can use to temporarily store data in memory so that you can more easily manipulate the data. For example, a data model could store information such as a person's name, age, and phone number, as follows:
<mx:Model id="myEmployee">
<name>
<first>John</first>
<last>Doe</last>
</name>
<department>Accounting</department>
<email>jdoe@goodcompany.com</email>
</mx:Model>
The fields of a data model can contain static data as above, or they can be bound to other objects. This binding allows you to pass data to and from the data model.
You can also define the data model in a separate XML file or a URL that returns XML. In that case, you can use the source property in the <mx:Model> tag to specify the XML file in the local web application directory, or to specify the HTTP URL that returns XML.
In the following examples, the content of the myContacts data model is an XML file named content.xml stored in the same folder as the MXML file. The content of the myCompany data model is a fictional HTTP URL that returns XML:
<mx:Model source="content.xml" id="myContacts"/> <mx:Model source="http://www.somesite.com/companyinfo.xml" id="myCompany"/>
If you hand-code your pages, you can use ActionScript or the <mx:Model> tag to define a data model. In general, you should use a tag for simple data structures and ActionScript for more complex structures and client-side business logic. However, Flex Builder only recognizes data models defined with the <mx:Model> tag.