1.用actionscript来绑定数据.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" fontSize="12">
<mx:Script>
<![CDATA[
[Bindable]
private var info:String="欢迎您的到来:";
]]>
</mx:Script>
<mx:Panel x="66" y="83" width="250" height="200" layout="absolute" title="数据绑定">
<mx:VBox x="0" y="0" height="100%" width="100%">
<mx:HBox width="100%" height="25">
<mx:Label text="请输入您的名字:" height="100%"/>
<mx:TextInput width="92" height="100%" id="myInput"/>
</mx:HBox>
<mx:Text width="212" id="myText" text="{info}{myInput.text}"/>
</mx:VBox>
</mx:Panel>
</mx:Application>

2.调用外部的类来绑定数据:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" fontSize="12">
<mx:Script>
<![CDATA[
import test.Test;
[Bindable]
private var info:String=Test.infos;
]]>
</mx:Script>
<mx:Panel x="66" y="83" width="250" height="200" layout="absolute" title="数据绑定">
<mx:VBox x="0" y="0" height="100%" width="100%">
<mx:HBox width="100%" height="25">
<mx:Label text="请输入您的名字:" height="100%"/>
<mx:TextInput width="92" height="100%" id="myInput"/>
</mx:HBox>
<mx:Text width="212" id="myText" text="{info}{myInput.text}"/>
</mx:VBox>
</mx:Panel>
</mx:Application>
Test:
package test
{
public class Test
{
public static const infos:String="欢迎您的到来:";
public function Test()
{
}
}
}
3.调用外部的AS来绑定数据:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" fontSize="12">
<mx:Script source="Test.as"/>
<mx:Panel x="66" y="83" width="250" height="200" layout="absolute" title="数据绑定">
<mx:VBox x="0" y="0" height="100%" width="100%">
<mx:HBox width="100%" height="25">
<mx:Label text="请输入您的名字:" height="100%"/>
<mx:TextInput width="92" height="100%" id="myInput"/>
</mx:HBox>
<mx:Text width="212" id="myText" text="{info}{myInput.text}"/>
</mx:VBox>
</mx:Panel>
</mx:Application>
Test.as:
[Bindable]
private var info:String="欢迎您的到来:";
660

被折叠的 条评论
为什么被折叠?



