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

Home
Flex
1.Chart
2.Components
3.Container
4.Data Model
5.Development
6.Effects
7.Event
8.Graphics
9.Grid
10.Style
Flex » Data Model » BindingUtilsScreenshots 
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.bindPropertylastNameField, "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
w__ww__.__j___av__a___2s___.__c___o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.