How to use iconFunction

I’m trying to customize the listbox component in such a way that I can add icons to each item. I’m trying to use the iconFunction but obviously I’m doing something wrong.

This is what I have:

list.iconFunction = function(item){
   trace("iconFunction called");
   var rating =;
   if (rating=="poor") {
      return "poorIcon";
   } else if (rating=="verygood") {
      return "verygoodIcon";
myList.addItem({label:"label 1", rating:"verygood"});
myList.addItem({label:"another label", rating:"poor"});


This doesn’t work and I’m a bit lost on how I should call this function.

Flash Help says:



Does anybody know how to use this?