A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Help with CellRenderer class for a comboBox

  1. #1
    Junior Member
    Join Date
    Mar 2007
    Posts
    21

    Help with CellRenderer class for a comboBox

    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:
    Code:
    var mySkin:CustomCellRenderer = new CustomCellRenderer(color1, color2, color3);
    myCB.dropdown.setStyle("cellRenderer", mySkin);
    Then in my custom cell renderer class I have:

    Code:
    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:isplayObjectContainer/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.

  2. #2
    Junior Member
    Join Date
    Mar 2007
    Posts
    21
    So if I remove the following:

    Code:
    setStyle("selectedUpSkin",up);
    setStyle("selectedDownSkin",dow);
            setStyle("selectedOverSkin",ov);
    the errors cease.

    Anyone know why setting the selected skins for a cellRenderer may cause this error?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center