# Programmatically created combobox error

**URL:** <https://forum.kirupa.com/t/programmatically-created-combobox-error/288617>\
**Category:** Uncategorized\
**Created:** [May 18, 2009, 11:47pm UTC](https://forum.kirupa.com/t/programmatically-created-combobox-error/288617 "2009-05-18T23:47:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Didi32](https://avatars.discourse-cdn.com/v4/letter/d/eb8c5e/32.png) [@Didi32](https://forum.kirupa.com/u/Didi32)\
**Post date:** [May 18, 2009, 11:47pm UTC](https://forum.kirupa.com/t/programmatically-created-combobox-error/288617/1 "2009-05-18T23:47:48Z")

</div>

Hi, I’m trying to create a combobox inside a package and add it to the stage later on. However, I’m getting the following error when I try to click on the combobox:  
Error #1009: Cannot access a property or method of a null object reference.

Here is the package for the combobox:

```auto

package {
    
    import flash.display.*;
    import flash.events.*;
    import flash.net.*;
    import fl.controls.*;
    
    
    
    public class Combo extends MovieClip {
        private var combo:ComboBox = new ComboBox();
        
        public function Combo(dropData:XMLList) {
            
            trace("dropData passed: " +dropData);
            combo.width = 300;
            combo.move(10, 10);
            
            addChild(combo);
            
            var i:uint;
            var numItems:int = dropData.drop.length();
            trace("numItems is: " + numItems);

            for (i = 0; i < numItems; i++) {
                var test = dropData.drop*.attribute("label");
                    combo.addItem({label:test});
            }

        }
        
    }
}

```

And here is what I have on the stage:

```auto

    var combo:Combo = new Combo(dropData);
    addChild(combo);

```

Now, the component is inside my library, and it actually appears when I test the swf, but if I try to click on it, I’m getting the error mentioned above and here in detail:

```auto

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at fl.containers::BaseScrollPane/drawBackground()
    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()
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
    at flash.display::DisplayObjectContainer/removeChild()
    at fl.controls::ComboBox/close()
    at fl.controls::ComboBox/focusOutHandler()

```

Thanks for your help,

Didi
