加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex 动态绑定BindingUtils.bindProperty

发布时间:2020-12-15 04:14:03 所属栏目:百科 来源:网络整理
导读:?xml version="1.0" encoding="utf-8"?? mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"? layout="absolute" initialize="init();"? mx:Script? import mx.binding.utils.BindingUtils;? import mx.binding.utils.ChangeWatcher;? private var w

<?xml version="1.0" encoding="utf-8"?>?
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"?
layout="absolute" initialize="init();">?

<mx:Script>?
import mx.binding.utils.BindingUtils;?
import mx.binding.utils.ChangeWatcher;?


private var watcher1:ChangeWatcher;?
private var watcher2:ChangeWatcher;?

/**?
*
动态绑定?
* @return void?
* **/?
private function Binding():void {?

//
绑定IDtxt2txtInput?
//
绑定属性为txtInputtext?
//
监视者IDtxt1txtInput?
//
监视者属性为txtInputtext?
watcher1 = BindingUtils.bindProperty(txt2,"text",txt1,"text");?

//
绑定IDtxtCombtxtInput?
//
绑定属性为txtInputtext?
//
监视者IDcombComboBox?
//
监视者属性为ComboBoxvalue?
watcher2 = BindingUtils.bindProperty(txtComb,comb,"value");?
}?

/**?
*
解除绑定?
* @return void?
* **/?
private function UnBinding():void {?
//
解除绑定?
watcher1.unwatch();?
watcher2.unwatch();?
}?
</mx:Script>?

<mx:ApplicationControlBar dock="true">?
<mx:Button label="
动态绑定" click="Binding();"/>?
<mx:Button label="
解除绑定" click="UnBinding();"/>?
</mx:ApplicationControlBar>?



<mx:VBox width="200" height="200">?

<mx:Spacer height="30"/>?

<mx:TextInput id="txt1"/>?
<mx:TextInput id="txt2"/>?

<mx:Spacer height="30"/>?

<mx:ComboBox id="comb">?
<mx:dataProvider>?
<mx:Array>?
<mx:String>Beijing</mx:String>?
<mx:String>Shanghai</mx:String>?
<mx:String>Hangzhou</mx:String>?
</mx:Array>?
</mx:dataProvider>?
</mx:ComboBox>?

<mx:TextInput id="txtComb"/>?
</mx:VBox>?
</mx:Application>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读