给控件绑定数据
给控件绑定数据
Flex提供提供了简单的方法绑定控件属性。在下面的例子中,使用大括号绑定TextArea控件text属性。
<?xml version="1.0"?>
<!-- mxml/BindingExample.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark">
<s:Panel title="My Application">
<s:VGroup left="10" right="10" top="10" bottom="10">
<s:Label text="Enter Text:"/>
<s:TextInput id="textinput1"
text="Hello"/>
<s:Label text="Bind Text to the TextArea control:"/>
<s:TextArea id="textarea1"
text="{textinput1.text}"/>
<s:Button label="Submit"
click="textinput1.text='Goodbye';"/>
</s:VGroup>
</s:Panel>
</s:Application>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark">
<s:Panel title="My Application">
<s:VGroup left="10" right="10" top="10" bottom="10">
<s:Label text="Enter Text:"/>
<s:TextInput id="textinput1"
text="Hello"/>
<s:Label text="Bind Text to the TextArea control:"/>
<s:TextArea id="textarea1"
text="{textinput1.text}"/>
<s:Button label="Submit"
click="textinput1.text='Goodbye';"/>
</s:VGroup>
</s:Panel>
</s:Application>
对应的swf文件
浙公网安备 33010602011771号