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
Property | Defined By | ||
---|---|---|---|
data : Object
Gets or sets an Object that represents the data that is
associated with a component. | ICellRenderer | ||
listData : ListData
Gets or sets the list properties that are applied to the cell--for example,
the index and selected values. | ICellRenderer | ||
selected : Boolean
Gets or sets a Boolean value that indicates whether the
current cell is selected. | ICellRenderer | ||
x : Number [write-only]
Sets the x coordinate of the cell renderer
| ICellRenderer | ||
y : Number [write-only]
Sets the y coordinate of the cell renderer
| ICellRenderer |
Method | Defined By | ||
---|---|---|---|
Sets the current cell to a specific mouse state. | ICellRenderer | ||
Sets the size of the data according to the pixel values specified by the width
and height parameters. | ICellRenderer |
data | property |
data:Object
Language Version: | ActionScript 3.0 |
Product Version: | Flash CS3 |
Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0 |
Gets or sets an Object that represents the data that is associated with a component. When this value is set, the component data is stored and the containing component is invalidated. The invalidated component is then automatically redrawn.
The data property represents an object containing the item in the DataProvider that the cell represents. Typically, the data property contains standard properties, depending on the component type. In CellRenderer in a List or ComboBox component the data contains a label, icon, and data properties; a TileList: a label and a source property; a DataGrid cell contains values for each column. The data property can also contain user-specified data relevant to the specific cell. Users can extend a CellRenderer for a component to utilize different properties of the data in the rendering of the cell.
Additionally, the labelField
, labelFunction
,
iconField
, iconFunction
, sourceField
,
and sourceFunction
elements can be used to specify which properties
are used to draw the label, icon, and source respectively.
Implementation
public function get data():Object
public function set data(value:Object):void
listData | property |
listData:ListData
Language Version: | ActionScript 3.0 |
Product Version: | Flash CS3 |
Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0 |
Gets or sets the list properties that are applied to the cell--for example,
the index
and selected
values. These list properties
are automatically updated after the cell is invalidated.
Implementation
public function get listData():ListData
public function set listData(value:ListData):void
selected | property |
selected:Boolean
Language Version: | ActionScript 3.0 |
Product Version: | Flash CS3 |
Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0 |
Gets or sets a Boolean value that indicates whether the
current cell is selected. A value of true
indicates
that the current cell is selected; a value of false
indicates that it is not.
Implementation
public function get selected():Boolean
public function set selected(value:Boolean):void
x | property |
y | property |
setMouseState | () | method |
public function setMouseState(state:String):void
Language Version: | ActionScript 3.0 |
Product Version: | Flash CS3 |
Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0 |
Sets the current cell to a specific mouse state. This method is necessary for the DataGrid to set the mouse state on an entire row when the user interacts with a single cell.
Parameters
state:String — A string that specifies a mouse state, such as "up" or "over".
|
setSize | () | method |
public function setSize(width:Number, height:Number):void
Language Version: | ActionScript 3.0 |
Product Version: | Flash CS3 |
Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0 |
Sets the size of the data according to the pixel values specified by the width
and height
parameters.
Parameters
width:Number — The width to display the cell renderer at, in pixels.
| |
height:Number — The height to display the cell renderer at, in pixels.
|
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); } } }
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