User Guide
List.iconFunction 785
List.iconFunction
Availability
Flash Player 6 (6.0.79.0).
Edition
Flash MX 2004.
Usage
listInstance.iconFunction
Description
Property; specifies a function that determines which icon each row uses to display its item.
This function receives a parameter,
item, which is the item being rendered, and must return a
string representing the icon’s symbol identifier.
Example
The following example adds icons that indicate whether a file is an image or a text document.
If the
data.fileExtension field contains a value of "jpg" or "gif", the icon used is
"pictureIcon", and so on.
my_list.iconFunction = function(item:Object):String {
var type:String = item.data.fileExtension;
if (type == "jpg" || type == "gif") {
return "pictureIcon";
} else if (type == "doc" || type == "txt") {
return "docIcon";
}
}
The following example sets the iconField property to the icon property of each item. To try
this code, drag a List component to the Stage, give it the instance name my_list, and create
three symbols with the instance names
flash, dreamweaver, and cf respectively. Add the
following code to Frame 1 in the timeline:
/**
Requires:
- List component on Stage (instance name: my_list)
- MovieClip/Graphic symbol in the Library with Linkage ID of "flashIcon"
*/
var my_list:mx.controls.List;
my_list.setSize(200, 100);
my_list.addItem({data:"flash", label:"Flash"});