I know a thread like this has come up several times, but I still can't seem to find the answer after diving several pages into Google. Basically, I have a list component in my library and I have manually edited the CellRenderer_* clips in the library to appeal to my design. However, what I am trying to find out is if it is still possible in AS3 to do two things: Alternating Row Colors (I can live without this) and different color TextFormats for each item in the List component.
Currently, I have a way to "setStyle" a List component by overriding the ListData member of the component:
Code:
package com.fwd.util {
import fl.controls.listClasses.CellRenderer;
import fl.controls.listClasses.ICellRenderer;
import flash.text.TextFormat;
import fl.controls.List;
public class ListController extends CellRenderer implements ICellRenderer {
public function ListController():void {
super();
}
public static function getStyleDefinition():Object {
return CellRenderer.getStyleDefinition();
}
override protected function drawBackground():void {
switch (_listData.row) {
case 0:
setStyle("textFormat", new TextFormat("Verdana", 12, 0xFFCC99));
break;
case 1:
setStyle("textFormat", new TextFormat("Verdana", 12, 0xFFCC99));
break;
case 2:
setStyle("textFormat", new TextFormat("Verdana", 12, 0x00CC33));
break;
case 3:
setStyle("textFormat", new TextFormat("Verdana", 12, 0x0066FF));
break;
case "3":
case "4":
setStyle("textFormat", new TextFormat("Verdana", 12, 0x333333));
break;
case "5":
setStyle("textFormat", new TextFormat("Verdana", 12, 0xFFFFFF));
break;
case "6":
case "7":
setStyle("textFormat", new TextFormat("Verdana", 12, 0xCC9900));
}
super.drawBackground();
}
}
}
Of course, the above code works when I add it to my List component:
Code:
var itemList:List = new List();
itemList.width = 200;
itemList.x = 10;
itemList.y = itemLabel.y + 30;
itemList.setStyle("cellRenderer", ListController);
newMuleTab.addChild(itemList);
However, the problem is this. The ListController class can't access the property of the List.addItem() object that I use to decide what TextFormat to use for the CellRenderer (The above is an example so it compiles. The object member I plan on using is "type" i.e. _listData.type throws an error). Has anyone done a workaround for this type of thing before? The application I'm writing really hinges on having different color text in the List component.