mx.binding.utils.BindingUtils; 类中绑定

<?xml version="1.0" encoding="utf-8"?>  
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">  
       
    <mx:Script>  
        [CDATA[   
            import model.UserVO;   
            import mx.controls.Label;   
            import mx.controls.TextInput;   
            import mx.binding.utils.BindingUtils;   
               
            private var userVO : UserVO = new UserVO();   
               
            private function init():void {   
                   
                for (var i : int = 0; i < 3; i++) {   
                    var nameLabel : Label = new Label();   
                    var emailLabel : Label = new Label();   
                       
                    myBox.addChild(nameLabel);   
                    myBox.addChild(emailLabel);   
                       
                    BindingUtils.bindProperty(nameLabel, "text", userVO, "name");   
                    BindingUtils.bindProperty(emailLabel, "text", userVO, "email");   
                }   
            }   
               
        ]]   
    </mx:Script>  
       
    <mx:HBox x="10" y="10" width="234">  
        <mx:TextInput id="nameInput" width="113" change="userVO.name = nameInput.text"/>  
        <mx:TextInput id="emailInput" width="107" change="userVO.email = emailInput.text"/>  
    </mx:HBox>  
    <mx:VBox id="myBox" x="10" y="38" width="234" height="175"/>  
       
</mx:Application>  



包含包:
package model   
{   
    [Bindable]   
    public class UserVO   
    {   
        public var name: String;   
           
        public var email: String;   
           
        public var online: Boolean = false;   
    }   
}  

你可能感兴趣的:(xml)