(Beta)
Package | fl.controls.listClasses |
Interface | public interface ICellRenderer |
Implementors | CellRenderer, DataGridCellEditor, ImageCell |
Language Version: | ActionScript 3.0 |
Product Version: | Flash CS3 |
Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0 |
Related API Elements
Public Properties
Property | Defined By |
---|
Public Methods
Method | Defined By |
---|
Property Detail
Method Detail
Examples How to use this example
ICellRendererExample.as
This example creates a custom cell renderer by implementing the ICellRenderer class.
To run the example, follow these steps:
- Add the List and Button components to the library.
- Save this code as ICellRendererExample.as in the same directory as your FLA file.
- Set the Document class in the FLA file to ICellRendererExample.
package { import fl.controls.List; import fl.data.DataProvider; import fl.events.ListEvent; import flash.display.Sprite; import flash.events.Event; public class ICellRendererExample extends Sprite { public function ICellRendererExample() { var dp:DataProvider = new DataProvider(); var totalEntries:Number = 42; var i:Number; for(i=0; i<totalEntries; i++) { dp.addItem( { label:Math.random(), data:null } ); } var myList = new List(); myList.setSize(300,300); myList.move(10,10); myList.setStyle('cellRenderer', MyRenderer); myList.dataProvider = dp; addChild(myList); } } }
MyRenderer.as
Save the following code as MyRenderer.as in the same directory as your FLA file:
package { import fl.controls.LabelButton; import fl.controls.listClasses.ICellRenderer; import fl.controls.listClasses.ListData; public class MyRenderer extends LabelButton implements ICellRenderer { private var _listData:ListData; private var _data:Object; public function MyRenderer() { } public function set listData(newListData:ListData):void { _listData = newListData; label = "Random: " + _listData.label; drawRandomColor(); } private function drawRandomColor():void { graphics.beginFill(Math.random()*0xFFFFFF); graphics.drawRect(0,0,20,20); graphics.endFill(); } public function get listData():ListData { return _listData; } public function set data(newData:Object):void { _data = newData; } public function get data():Object { return _data; } } }
Wed Nov 21 2018, 06:34 AM -08:00