fl.controls.listClasses
public class ListData
继承ListData Inheritance Object
子类 TileListData

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9.0.28.0

ListData 是一种信使类,用于保存与基于列表的组件中的特定单元格相关的信息。 该信息包括与单元格关联的标签和图标(无论是否选择了单元格),以及单元格在列表中的位置(通过行和列来表示)。

每当 ListData 组件变为无效时,都会为单元格渲染器创建一个新的 ListData 组件。

查看示例




公共 属性
 属性定义方
  column : uint
[read-only] 数据项目所在的列。
ListData
 Inheritedconstructor : Object
对类对象或给定对象实例的构造函数的引用。
Object
  icon : Object
[read-only] 一个表示 List 组件中项目的图标的类,根据 List 类方法计算得出。
ListData
  index : uint
[read-only] 数据提供者中项目的索引。
ListData
  label : String
[read-only] 要在单元格中显示的标签。
ListData
  owner : UIComponent
[read-only] 对拥有此项目的 List 对象的引用。
ListData
 Inheritedprototype : Object
[static] 对类或函数对象的原型对象的引用。
Object
  row : uint
[read-only] 数据项目所在的行。
ListData
公共 方法
 方法定义方
  
ListData(label:String, icon:Object, owner:UIComponent, index:uint, row:uint, col:uint = 0)
按照参数的指定创建 ListData 类的新实例。
ListData
 Inherited
指示对象是否已经定义了指定的属性。
Object
 Inherited
指示 Object 类的实例是否在指定为参数的对象的原型链中。
Object
 Inherited
指示指定的属性是否存在、是否可枚举。
Object
 Inherited
设置循环操作动态属性的可用性。
Object
 Inherited
返回指定对象的字符串表示形式。
Object
 Inherited
返回指定对象的原始值。
Object
属性详细信息
column属性
column:uint  [read-only]

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9.0.28.0

数据项目所在的列。 在 List 中,该值始终为 0。


实现
    public function get column():uint
icon属性 
icon:Object  [read-only]

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9.0.28.0

一个表示 List 组件中项目的图标的类,根据 List 类方法计算得出。


实现
    public function get icon():Object
index属性 
index:uint  [read-only]

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9.0.28.0

数据提供者中项目的索引。


实现
    public function get index():uint
label属性 
label:String  [read-only]

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9.0.28.0

要在单元格中显示的标签。


实现
    public function get label():String
owner属性 
owner:UIComponent  [read-only]

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9.0.28.0

对拥有此项目的 List 对象的引用。


实现
    public function get owner():UIComponent
row属性 
row:uint  [read-only]

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9.0.28.0

数据项目所在的行。


实现
    public function get row():uint
构造函数详细信息
ListData()构造函数
public function ListData(label:String, icon:Object, owner:UIComponent, index:uint, row:uint, col:uint = 0)

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9.0.28.0

按照参数的指定创建 ListData 类的新实例。

参数
label:String — 要在此单元格中显示的标签。
 
icon:Object — 要在此单元格中显示的图标。
 
owner:UIComponent — 拥有此单元格的组件。
 
index:uint — 数据提供者中项目的索引。
 
row:uint — 此项目所在的行。 在 List 或 DataGrid 中,该值对应于索引。 在 TileList 中,该值可能与索引不同。
 
col:uint (default = 0) — 此项目所在的列。 在 List 中,该值始终为 0。
示例 如何使用示例

此示例演示如何访问单元格渲染器的 listData 属性。

若要运行该示例,请按照下列步骤操作:

  1. 将 List 和 Button 组件添加到库中。
  2. 将该代码作为 ListDataExample.as 另存到 FLA 文件所在的同一目录中。
  3. 将 FLA 文件中的 Document 类设置为 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;
        }
    }
}




 

评论添加到页面后给我发送电子邮件 | 评论报告

当前页: http://livedocs.adobe.com/flash/9.0_cn/ActionScriptLangRefV3/fl/controls/listClasses/ListData.html