主文件关键代码如下:
import fl.controls.listClasses.CellRenderer; Arr.push({data:"images/ie.jpg",//此处要跟后面类中的名称一致 "Job No.":JobListXML[i].@JobNo }) var colH:DataGridColumn = new DataGridColumn(); colH=DG.getColumnAt(DG.getColumnIndex("ico"));//这里是列名 colH.cellRenderer = LoaderCellRenderer;
LoaderCellRenderer.as
package { import fl.containers.UILoader; import fl.controls.listClasses.ICellRenderer; import fl.controls.listClasses.ListData; import fl.core.InvalidationType; import fl.data.DataProvider; import flash.events.Event; public class LoaderCellRenderer extends UILoader implements ICellRenderer { protected var _data:Object; protected var _listData:ListData; protected var _selected:Boolean; public function LoaderCellRenderer():void { super(); } public function get data():Object { return _data; } public function set data(value:Object):void { _data = value; source = value.data ; //此处要跟前面的列名称一致 } public function get listData():ListData { return _listData; } public function set listData(value:ListData):void { _listData = value; invalidate(InvalidationType.DATA); invalidate(InvalidationType.STATE); } public function get selected():Boolean { return _selected; } public function set selected(value:Boolean):void { _selected = value; invalidate(InvalidationType.STATE); } public function setMouseState(state:String):void { } } }