flex 使用绑定,常用的几种方式
<?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="955" minHeight="600">
<fx:Script>
<![CDATA[
[Bindable]
private var s:String;
private function changing():void{
s=String(hs.value);
}
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout verticalAlign="middle" horizontalAlign="center" />
</s:layout>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:Label text="大括号绑定:" />
<s:TextInput id="t1" />
<s:TextInput id="t2" text="{t1.text}" />
<s:Label text="MXML声明绑定" />
<fx:Binding source="t3.text" destination="t4.text" />
<s:TextInput id="t3" />
<s:TextInput id="t4" />
<s:Label text="Bindable绑定:" />
<s:TextInput text="{s}" />
<s:HSlider width="100" maximum="100" minimum="0" id="hs" change="changing()" />
</s:Application>