Bind Model with BindingUtils.bindProperty : BindingUtils « Data Model « Flex






Bind Model with BindingUtils.bindProperty

Bind Model with BindingUtils.bindProperty
         
<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="vertical"
    creationComplete="initHandler();">

    <mx:Script>
        
            import mx.binding.utils.BindingUtils;
            private function initHandler():void
            {
                BindingUtils.bindProperty( lastNameField, "text",usermodel, ["name", "lastName"] );
            }
            private function clickHandler():void
            {
                usermodel.name.firstName = fNameInput.text;
                usermodel.name.lastName = lNameInput.text;
                usermodel.birth.date = dateInput.text;
            }
      
    </mx:Script>
    <mx:Model id="usermodel">
        <user>
            <name>
                  <firstName>A</firstName>
                  <lastName>B</lastName>
           </name>
           <birth>
                  <date>2101</date>
           </birth>
        </user>
    </mx:Model>
    <mx:Binding source="usermodel.birth.date" destination="dateField.text" />
    <mx:Form>
        <mx:FormItem label="First Name:">
            <mx:Text text="{usermodel.name.firstName}" />
     </mx:FormItem>
        <mx:FormItem label="Last Name:">
            <mx:Text id="lastNameField" />
        </mx:FormItem>
        <mx:FormItem label="Birthday:">
            <mx:Text id="dateField" />
        </mx:FormItem>
    </mx:Form>
    <mx:HRule />

    <mx:Form>
        <mx:FormItem label="First Name:">
             <mx:TextInput id="fNameInput" />
        </mx:FormItem>
        <mx:FormItem label="Last Name:">
            <mx:TextInput id="lNameInput" />
        </mx:FormItem>
        <mx:FormItem label="Birthday:">
            <mx:TextInput id="dateInput" />
        </mx:FormItem>
        <mx:FormItem label="Submit Changes">
             <mx:Button label="ok" click="clickHandler();" />
        </mx:FormItem>
    </mx:Form>
</mx:Application>

   
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Use BindingUtils to bind propertyUse BindingUtils to bind property
2.Data Binding Through the ActionScript BindingUtils ClassData Binding Through the ActionScript BindingUtils Class
3.Bind with BindingUtils.bindSetterBind with BindingUtils.bindSetter
4.Bind Setter using setter methodBind Setter using setter method