fl.controls.listClasses

# ListData - AS3 Flash

Package | fl.controls.listClasses
Class | public class ListData
Inheritance | ListData Object
Subclasses | TileListData

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.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

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | column : uint [read-only] The column in which the data item is displayed. | ListData
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | icon : Object [read-only] A class that represents the icon for the item in the List component, computed from the List class method. | ListData
|  | index : uint [read-only] The index of the item in the data provider. | ListData
|  | label : String [read-only] The label to be displayed in the cell. | ListData
|  | owner : UIComponent [read-only] A reference to the List object that owns this item. | ListData
|  | row : uint [read-only] The row in which the data item is displayed. | ListData

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | ListData(label:String, icon:Object, owner:UIComponent, index:uint, row:uint, col:uint = 0) Creates a new instance of the ListData class as specified by its parameters. | ListData
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | toLocaleString():String Returns the string representation of this object, formatted according to locale-specific conventions. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | valueOf():Object Returns the primitive value of the specified object. | Object

Property Detail

### column

property

`column:uint` [read-only]

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.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

property

`icon:Object` [read-only]

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.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

property

`index:uint` [read-only]

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

The index of the item in the data provider.

Implementation
`public function get index():uint`

### label

property

`label:String` [read-only]

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

The label to be displayed in the cell.

Implementation
`public function get label():String`

### owner

property

`owner:UIComponent` [read-only]

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

A reference to the List object that owns this item.

Implementation
`public function get owner():UIComponent`

### row

property

`row:uint` [read-only]

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

The row in which the data item is displayed.

Implementation
`public function get row():uint`
Constructor Detail

### ListData

()
Constructor

`public function ListData(label:String, icon:Object, owner:UIComponent, index:uint, row:uint, col:uint = 0)`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.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.

Examples How to use this example
ListDataExample.as
This example illustrates how to access the `listData` property of a cell renderer.

To run the example, follow these steps:

1. Add the List and Button components to the library.
2. Save this code as ListDataExample.as in the same directory as your FLA file.
3. Set the Document class in the FLA file to ListDataExample.

Copy

    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;
            }
        }
    }

© 2015 Adobe Systems Incorporated. All rights reserved.
Mon Apr 10 2017, 12:28 PM -07:00