I am trying to dynamically skin a ComboBox at runtime, based on color values I am reading from a database using amfphp. Everything is working great, except for one thing.
I am having problems extending the CellRenderer class.
I current have this:
var mySkin:CustomCellRenderer = new CustomCellRenderer(color1, color2, color3);
myCB.dropdown.setStyle("cellRenderer", mySkin);
Then in my custom cell renderer class I have:
package {
import fl.controls.listClasses.CellRenderer;
import flash.text.TextFormat;
import OverSkin;
import UpSkin;
import DownSkin;
public class CustomCellRenderer extends CellRenderer{
private var _rectangle:Shape;
private var _bgColor:uint;
private var ov:OverSkin;
private var dow:DownSkin;
private var up:UpSkin;
public function CustomCellRenderer (Color1:uint,Color2:uint, Color3:uint) {
ov = new OverSkin(Color1);
dow = new DownSkin(Color2);
up = new UpSkin(Color3);
setStyle("upSkin",up);
setStyle("downSkin",dow);
setStyle("overSkin",ov);
setStyle("selectedUpSkin",up);
setStyle("selectedDownSkin",dow);
setStyle("selectedOverSkin",ov);
}
}
}
This all seems to be working fine, but I am running into one problem.
I click the comboBox to pull up the drop down, and it displays fine, I select an item and the drop down closes. I then go back to click the combobox and I get the following error:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at fl.controls::List/drawList()
at fl.controls::List/draw()
at fl.core::UIComponent/drawNow()
at fl.controls::List/scrollToIndex()
at fl.controls::SelectableList/scrollToSelected()
at fl.controls::ComboBox/open()
at fl.controls::ComboBox/onToggleListVisibility()
Can anyone point me to a tutorial or some sample code of how to implement the cellRenderer for a comboBox? I have been searching everywhere but cannot seem to find any good examples.