第一种,使用{}绑定
<mx:TextInput id="input" />
<mx:Label text="{input.text}" />
第二种,<mx:Binding> 绑定
<mx:Application xmlns:mx=http://www.adobe.com/2006/mxml layout="vertical">
<mx:TextInput id="inputSource" />
<mx:Label id="labelTarget" />
<mx:Binding source="inputSource.text" destination="labelTarget.text" />
</mx:Application>
第三种,使用 BindingUtils工具类
BindingUtils.bindProperty ( target, "targetProperty", source, "sourceProperty" );
- target:Object - 目标
- targetProperty:目标属性,String类型
- source:Object - 绑定源
- sourceProperty:源属性,String类型
<mx:Application xmlns:mx=http://www.adobe.com/2006/mxml layout="vertical">
<mx:TextInput id="inputSource" />
<mx:Label id="labelTarget" />
</mx:Application>
<script>
BindingUtils.bindProperty (labelTarget,"text",inputSource,"text");
</script>