简单的对于变量的[Bindable] 使用

对与触发事件修改控件属性,可以通过:

<fx:Script>
    <![CDATA[
        private function my_button_clickhandler():void{
        my_text.text = "clicked"
        }
    ]]>
</fx:Script>
<s:Label text="Hello" x="100" y="50" id="my_text" />   
<s:Button x="100" y="100" id = "my_button" label  = "my_button" click="my_button_clickhandler()" />

 

另外可以通过给属性绑定变量,来达到修改控件属性的目的

 

<fx:Script>
    <![CDATA[
        [Bindable]
        private var dtext:String = "Hello";
        private function my_button_clickhandler():void{
            dtext = "clicked"
        }
    ]]>
</fx:Script>
<s:Label text="{dtext}" x="100" y="50" id="my_text" />  
<s:Button x="100" y="100" id = "my_button" label  = "my_button" click="my_button_clickhandler()" />

 

这时候就要用到[Bindable](当然元数据 [Bindable]的使用并不仅限于此,有兴趣可以参考:http://gain-loss.org/?p=71

实际上这个标识的作用是通知编译器加入绑定事件:使得当变量(dtext)变化时候,所有受其影响的变量都跟着改变。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值