Language Version : | ActionScript 3.0 |
Player Version : | Flash Player 9.0.28.0 |
ListData is a messenger class that holds information relevant to a specific
cell in a list-based component. This information includes the label and icon that are
associated with the cell; whether or not the cell is selected; and the position of
the cell in the list by row and column.
A new ListData component is created for a cell renderer
each time it is invalidated.
View the examples
column:uint
[read-only]
Language Version : | ActionScript 3.0 |
Player Version : | Flash Player 9.0.28.0 |
The column in which the data item is displayed. In a list,
this value is always 0.
Implementation
public function get column():uint
icon:Object
[read-only]
Language Version : | ActionScript 3.0 |
Player Version : | Flash Player 9.0.28.0 |
A class that represents the icon for the item in the List component,
computed from the List class method.
Implementation
public function get icon():Object
index:uint
[read-only]
Language Version : | ActionScript 3.0 |
Player Version : | Flash Player 9.0.28.0 |
The index of the item in the data provider.
Implementation
public function get index():uint
label:String
[read-only]
Language Version : | ActionScript 3.0 |
Player Version : | Flash Player 9.0.28.0 |
The label to be displayed in the cell.
Implementation
public function get label():String
owner:UIComponent
[read-only]
Language Version : | ActionScript 3.0 |
Player Version : | Flash Player 9.0.28.0 |
A reference to the List object that owns this item.
Implementation
public function get owner():UIComponent
row:uint
[read-only]
Language Version : | ActionScript 3.0 |
Player Version : | Flash Player 9.0.28.0 |
The row in which the data item is displayed.
Implementation
public function get row():uint
public function ListData(label:String, icon:Object, owner:UIComponent, index:uint, row:uint, col:uint = 0)
Language Version : | ActionScript 3.0 |
Player Version : | Flash Player 9.0.28.0 |
Creates a new instance of the ListData class as specified by its parameters.
Parameters
| label:String — The label to be displayed in this cell.
|
|
| icon:Object — The icon to be displayed in this cell.
|
|
| owner:UIComponent — The component that owns this cell.
|
|
| index:uint — The index of the item in the data provider.
|
|
| row:uint — The row in which this item is being displayed. In a List or
DataGrid, this value corresponds to the index. In a TileList, this
value may be different than the index.
|
|
| col:uint (default = 0 ) — The column in which this item is being displayed. In a List,
this value is always 0.
|
This example illustrates how to access the
listData
property of a cell renderer.
To run the example, follow these steps:
- Add the List and Button components to the library.
- Save this code as ListDataExample.as in the same directory as your FLA file.
- Set the Document class in the FLA file to ListDataExample.
package
{
import fl.controls.List;
import fl.controls.listClasses.CellRenderer;
import fl.controls.listClasses.ListData;
import fl.events.ListEvent;
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
public class ListDataExample extends Sprite
{
var sampleItem1:Object = { label:"John Alpha" };
var sampleItem2:Object = { label:"Mary Bravo" };
var sampleItem3:Object = { label:"Trevor Gamma" };
var sampleItem4:Object = { label:"Susan Delta" };
var myList:List;
var tf:TextField;
public function ListDataExample() {
createList();
tf = new TextField();
tf.x = 10;
tf.y = 125;
addChild(tf);
}
private function createList():void {
myList = new List();
myList.move(10,10);
myList.addItem(sampleItem1);
myList.addItem(sampleItem2);
myList.addItem(sampleItem3);
myList.addItem(sampleItem4);
myList.rowCount = 4;
myList.addEventListener(ListEvent.ITEM_CLICK,listItemSelected);
addChild(myList);
}
private function listItemSelected(e:ListEvent):void {
var cr:CellRenderer = myList.itemToCellRenderer(e.item) as CellRenderer;
var listData:ListData = cr.listData;
tf.text = "Row selected: " + listData.row;
}
}
}
© 2004-2007 Adobe Systems Incorporated. All rights reserved.
Tue Mar 18 2008, 12:59 PM GMT-07:00