]]> </mx:Script> <!-- this list can use an inline item renderer because the array that the List is using as a dataprovider consists of simple object --> <mx:ListdataProvider="{simpleArray}"> <mx:itemRenderer> <mx:Component> <mx:Labelcolor="#007700"/> </mx:Component> </mx:itemRenderer> </mx:List> <!-- the list component here requires a custom renderer because we're passing any object to it, which means that the renderer will need to know how to handle each field in the item --> <mx:ListitemRenderer="oreilly.cookbook.SevenOneRenderer" dataProvider="{DataHolder.genericCollectionOne}"/> <!-- here we can use a proper drop in item renderer because the DataGrid handles each field in the Object separately --> <mx:DataGriddataProvider="{DataHolder.genericCollectionOne}"> <mx:columns> <mx:DataGridColumndataField="name"/> <mx:DataGridColumndataField="age"/> <mx:DataGridColumndataField="appearance" width="200"> <mx:itemRenderer> <mx:Component> <!-- note that any component placed here must extend IDataRenderer and have a data property that properly displays any data passed to the data setter method --> <!- 原文这里容易让人误解,其实把这里的and 换成or 就对了,因为这里的组件不 extend IDataRenderer也可以,只要它有data属性就可以。--> <mx:TextArea/> </mx:Component> </mx:itemRenderer> </mx:DataGridColumn> </mx:columns> </mx:DataGrid> </mx:VBox>