# How to pass a var to a custom CellRenderer class?

**URL:** <https://forum.kirupa.com/t/how-to-pass-a-var-to-a-custom-cellrenderer-class/281098>\
**Category:** flash\
**Created:** [February 4, 2009, 9:27pm UTC](https://forum.kirupa.com/t/how-to-pass-a-var-to-a-custom-cellrenderer-class/281098 "2009-02-04T21:27:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![savetheworld](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@savetheworld](https://forum.kirupa.com/u/savetheworld)\
**Post date:** [February 4, 2009, 9:27pm UTC](https://forum.kirupa.com/t/how-to-pass-a-var-to-a-custom-cellrenderer-class/281098/1 "2009-02-04T21:27:56Z")

</div>

I have a combobox that I need to style with colors from xml. I call this XML file in the same class that has my combobox instance and break out the color I need to a var.

I then use MyCellRenderer (a class that extends CellRenderer) to style the drop down list items like so:

```auto
myComboBox.dropdown.setStyle('cellRenderer', MyCellRenderer );

```

This all works perfectly with a hardcoded color already inside the MyCellRenderer class.

My problem is when I instantiate MyCellRenderer and try to pass the color through I get the following error when I click the combobox open:

```auto
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/callLaterDispatcher()

```

Is it possible to instantiate a class that extends CellRenderer? If not why not?

And the big one… how can I pass a variable to my custom CellRenderer class?

Thanks!  
Mary
