Data Binding With fx:Model tag in Flex4

Ads

The tag represent a data in XML format. It is a MXML based tag.

Data Binding with fx:Model tag in Flex4:

The <fx:Model> tag represent a data in XML format. It is
a MXML based tag.
This tag contains a data in tree of objects when a data in a hierarchy. It
contains leave node and these node of objects have a scalar values.
The tag is <fx:Model>.

Syntax are given below.

<?xml version=

"1.0"encoding="utf-8"?>

<s:Application xmlns:fx=

"http://ns.adobe.com/mxml/2009"

xmlns:s=

"library://ns.adobe.com/flex/spark"

xmlns:mx=

"library://ns.adobe.com/flex/mx"

minWidth=

"955"minHeight="600">

<fx:Declarations>

<fx:Model id=

"registration">

<registration>

<uname>{unametxt.text}</uname>

<emailid>{emailtxt.text}</emailid>

<phoneno>{phonetxt.text}</phoneno>

<zipcode>{ziptxt.text}</zipcode>

<socials>{socialstxt.text}</socials>

</registration>

</fx:Model>

</fx:Declarations>

Example:

<?xml version=

"1.0"encoding="utf-8"?>

<s:Application xmlns:fx=

"http://ns.adobe.com/mxml/2009"

xmlns:s=

"library://ns.adobe.com/flex/spark"

xmlns:mx=

"library://ns.adobe.com/flex/mx"

minWidth=

"955"
minHeight="600">

<fx:Declarations>

<fx:Model id=

"registration">

<registration>

<uname>{unametxt.text}</uname>

<emailid>{emailtxt.text}</emailid>

<phoneno>{phonetxt.text}</phoneno>

<zipcode>{ziptxt.text}</zipcode>

<socials>{socialstxt.text}</socials>

</registration>

</fx:Model>

</fx:Declarations>

<s:Panel title=

"Data
Binding with fx:model tag" width="293">

<mx:Form width=

"291"
backgroundColor="#101446"
color="#FFFFFF">

<mx:FormItem label=

"User
Name">

<s:TextInput id=

"unametxt"
width="100%" color="#000000"/>

</mx:FormItem>

<mx:FormItem label=

"Email-Id">

<s:TextInput id=

"emailtxt"
width="100%" color="#000000"/>

</mx:FormItem>

<mx:FormItem label=

"Phone
no.">

<s:TextInput id=

"phonetxt"
width="100%" color="#000000"/>

</mx:FormItem>

<mx:FormItem label=

"Zip
Code">

<s:TextInput id=

"ziptxt"
width="60%" color="#000000"/>

</mx:FormItem>

<mx:FormItem label=

"Social
Security">

<s:TextInput id=

"socialstxt"
width="100%" color="#000000"/>

</mx:FormItem>

<mx:FormItem direction=

"horizontal">

<s:Button id=

"submitbtn"
label="Submit"

chromeColor=

"#5F1B0C"/>

<s:Button id=

"cancelbtn"
label="Cancel"

chromeColor=

"#5F1B0C"/>

<

/mx:FormItem>

</mx:Form>

</s:Panel>

</s:Application>

Output:

Running Application:

To view this page ensure that Adobe Flash Player version
10.0.0 or greater is installed.

Either scripts and active content are not permitted to run or Adobe Flash Player version
10.0.0 or greater is not installed.