Flex-数据绑定
2012-03-26 19:55
260 查看
Flex绑定,有三种方式。
1、直接通过{}实现绑定;
eg:
2、简单的绑定方式。
在<fx:Script>代码中,通过"[Bindable]"关键字实现绑定
3、使用<fx:Binding source="绑定源" destination="目标" />实现绑定
*使用<fx:Binding 中可以通过 twoWay 属性实现双向绑定 twoWay="true"
绑定的代码:
1、直接通过{}实现绑定;
eg:
<s:TextInput id="txtFirst"/> <s:TextInput id="txtSecond" text="{txtFirst.text}"/>//实现第二个输入框值与第一个同步
2、简单的绑定方式。
在<fx:Script>代码中,通过"[Bindable]"关键字实现绑定
3、使用<fx:Binding source="绑定源" destination="目标" />实现绑定
*使用<fx:Binding 中可以通过 twoWay 属性实现双向绑定 twoWay="true"
绑定的代码:
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="400" minHeight="300"> <s:layout> <s:VerticalLayout verticalAlign="middle" horizontalAlign="center" /> </s:layout> <fx:Declarations> </fx:Declarations> <fx:Binding source="txtFirst.text" destination="labFirst.text" /> <fx:Script> <![CDATA[ [Bindable] private var str:String; private function drogSlider():void{ str = String(sliderFirst.value); } ]]> </fx:Script> <s:Label id="labFirst" text="初始值"/> <s:TextInput id="txtFirst"/> <s:TextInput id="txtSecond" text="{txtFirst.text}"/> <s:HSlider id="sliderFirst" change="drogSlider();"/> <s:Label id="labSecond" text="划条值是:{str}"/> </s:Application>
相关文章推荐
- Flex学习笔记(六)——数据的绑定(Binding)
- Flex: 数据绑定将无法检测对“***”的指定
- flex省市的comboBox下拉级联的数据即时绑定
- FLEX数据绑定要点(转)
- Flex 数据绑定易犯的错误:普遍的误用和错误
- Flex中数据绑定。
- FLEX中datagrid数据绑定
- Flex数据绑定陷阱(二)
- 关于Flex中用大括号{}进行数据绑定遇到的问题
- as3 非flex项目实现数据绑定
- Flex绑定数据的方式
- Flex 4.5中数据绑定的原理
- Flex数据绑定(一)
- flex数据绑定
- Flex 数据的三种绑定方式
- Flex 的数据绑定观察
- FLEX COMBOBOX前端绑定数据
- Flex中数据绑定
- FLex数据绑定
- FLEX学习笔记----数据绑定