数据绑定学习笔记

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="欢迎您的到来:";

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值