User Guide
790 List component
Example
The following example sets the labelField property to be the "name" field of each item.
“Nina” would display as the label for the item added in the second line of code:
var my_list:mx.controls.List;
my_list.labelField = "name";
my_list.addItem({name: "Nina", age: 25});
See also
List.labelFunction
List.labelFunction
Availability
Flash Player 6 (6.0.79.0).
Edition
Flash MX 2004.
Usage
listInstance.labelFunction
Description
Property; specifies a function that determines which field (or field combination) of each item
to display. This function receives one parameter,
item, which is the item being rendered, and
must return a string representing the text to display.
Example
The following example makes the label display some formatted details of the items:
var my_list:mx.controls.List;
my_list.setSize(300, 100);
// Define how list data will be displayed.
my_list.labelFunction = function(item_obj:Object):String {
var label_str:String = item_obj.label + " - Code is: " + item_obj.data;
return label_str;
}
// Add data to list.
my_list.addItem({data:"f", label:"Flash"});
my_list.addItem({data:"d", label:"Dreamweaver"});
my_list.addItem({data:"c", label:"ColdFusion"});