<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.collections.ArrayCollection; [Bindable] public var ac:ArrayCollection=new ArrayCollection([ {num:"第1个checkbox",select:false}, {num:"第2个checkbox",select:false}, {num:"第3个checkbox",select:false}, {num:"第4个checkbox",select:false}, ]); private function test():void{ for(var i:int;i<ac.length;i++){ var item:Object=ac.getItemAt(i); Alert.show(item.num+" "+item.select); } } ]]> </mx:Script> <mx:TileList x="195" y="75" dataProvider="{ac}" columnCount="1" id="titleList" width="100"> <mx:itemRenderer> <mx:Component> <mx:CheckBox selected="{data.select}" label="{data.num}" click="data.select=!data.select"/> </mx:Component> </mx:itemRenderer> </mx:TileList> <mx:Button x="300" y="223" label="看看" click="test()"/> </mx:Application>
说明:以上的思路可以用到datagrid等组件中单元格的渲染,首先checkbox是否选中绑定到数据源中的一个属性上,当checkbox点击时改变数据源的值。