Flex 动态绑定BindingUtils.bindProperty

所属分类: 网页制作 / Flash 阅读数: 1972
收藏 0 赞 0 分享
关键字:BindingUtils.bindProperty
需导入:import mx.binding.utils.BindingUtils;
/**
* 动态绑定
* @params site:Object 被绑定对象
* @params prop:String 被绑定对象的属性,如textInput的text属性
* @params host:Object 监视者对象
* @params chain:Object 监视者对象的属性
* @return ChangeWatcher
* **/
BindingUtils.bindProperty(site:Object,prop:String,host:Object,chain:Object);
复制代码 代码如下:

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

    <mx:Script>
        <!--[CDATA[
            import mx.binding.utils.BindingUtils;
            import mx.binding.utils.ChangeWatcher;

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

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

                //绑定ID为txt2的txtInput
                //绑定属性为txtInput的text
                //监视者ID为txt1的txtInput
                //监视者属性为txtInput的text
                watcher1 = BindingUtils.bindProperty(txt2,"text",txt1,"text");

                //绑定ID为txtComb的txtInput
                //绑定属性为txtInput的text
                //监视者ID为comb的ComboBox
                //监视者属性为ComboBox的value
                watcher2 = BindingUtils.bindProperty(txtComb,"text",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>
更多精彩内容其他人还在看

Flex 创建一个自定义风格的HRule或VRule

Flex中如何通过strokeWidth, strokeColor和shadowColor样式,创建一个自定义风格的HRule或VRule
收藏 0 赞 0 分享

Flex Gumbo 通过textJustify样式设置TextBox文字对齐的例子

接下来的例子演示了Flex Gumbo中如何通过textJustify样式,设置TextBox文字对齐。
收藏 0 赞 0 分享

Flex Gumbo 通过smooth属性设置BitmapGraphic对象平滑度的例子

接下来的例子演示了Flex Gumbo中如何通过smooth属性,设置BitmapGraphic对象平滑度。
收藏 0 赞 0 分享

Flex Javascript交互实现代码

删除swf这里需要提醒下,因为embedSWF是替换标签,而不是填充。
收藏 0 赞 0 分享

Flex 动态绑定BindingUtils.bindProperty

Flex 动态绑定BindingUtils.bindProperty实现代码。
收藏 0 赞 0 分享

解决Ajax悬停效果,无法遮蔽FLASH的问题

但遇到的问题是:很多的页面中有FALSH导航栏,或者FLASH广告动画等,这些FLASH是不会自动被CSS样式遮蔽的.怎么办呢?
收藏 0 赞 0 分享

Flex 对象持久化

总有人问我关于Flex对象序列化和持久化的问题,很多人认为对象不能拷贝到服务器,其实浅度的拷贝是可以做到的。
收藏 0 赞 0 分享

XML TO ArrayCollection 两种实现方式

最近研究FLEX,在网上看过100遍同一篇文章,结果测试不通,不知道到底能不能跑通,最后翻资料自己试验处理。
收藏 0 赞 0 分享

java TO ArrayCollection

因为new ArrayCollection 需要 array对象,event.result是空间返回对象(JAVA方法返回值)所以类型不同无法使用new 构造ArrayCollection ,可是恶心的FLEX偏偏支持javalist=ArrayCollection
收藏 0 赞 0 分享

Flex DataGrid DataGridColumn数据颜色多样化-类型替换

用得多了,发觉自己了解的真的是九牛之一毛都没有,最近用到了从后台读出数据时显示的问题,相信很多人都有用整形数据来代替字符串数据的情况
收藏 0 赞 0 分享
查看更多