<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
<mx:Panel width="392" height="300" layout="absolute">
<mx:Label x="19" y="10" text="{user}" width="171" height="20"/>
<mx:Button x="216" y="8" label="测试Bindable" click="bind()" width="105"/>
<mx:DataGrid x="19" y="58" dataProvider="{arr}">
<mx:columns>
<mx:DataGridColumn headerText="year" dataField="year"/>
<mx:DataGridColumn headerText="city" dataField="city"/>
<mx:DataGridColumn headerText="provice" dataField="provice"/>
<mx:DataGridColumn headerText="total" dataField="total"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.collections.ArrayCollection;
[Bindable]
private var user:String="HELLO";
[Bindable]
private var arr:ArrayCollection=new ArrayCollection([
{year:2009,city:"Shanghai",provice:"上海",total:580000},
{year:2009,city:"Beijing",provice:"河北省",total:7852020},
{year:2009,city:"Nanjing",provice:"江苏省",total:895145},
{year:2009,city:"Hangzhou",provice:"浙江省",total:4132415}]);
//修改了绑定的user和arr,并没有修改label和datagrid
private function bind():void{
this.user="HEllo22";
arr.removeItemAt(3);
}
]]>
</mx:Script>
</mx:Application>
flex Bindable使用讲解
最新推荐文章于 2017-05-26 08:14:56 发布