# Can't addChild after deleting it (Error #1009)

**URL:** <https://forum.kirupa.com/t/cant-addchild-after-deleting-it-error-1009/332547>\
**Category:** flash\
**Created:** [July 19, 2014, 2:54pm UTC](https://forum.kirupa.com/t/cant-addchild-after-deleting-it-error-1009/332547 "2014-07-19T14:54:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikel](https://avatars.discourse-cdn.com/v4/letter/n/b782af/32.png) [@nikel](https://forum.kirupa.com/u/nikel)\
**Post date:** [July 19, 2014, 2:54pm UTC](https://forum.kirupa.com/t/cant-addchild-after-deleting-it-error-1009/332547/1 "2014-07-19T14:54:27Z")

</div>

Hello, I’m trying to delete and create new movieclip but I’m getting errors. Here’s my code:

```auto
function onNumericStChange(event:Event):void {
    subunits = event.target.value;
    isEditSet = false;
    
    container.parent.removeChild(container);
    
    if(container.parent) {
        container.parent.removeChild(container);
    }
    
    //Create a container movieclip (mc) to hold the attached items
    var container:MovieClip = new MovieClip();
    //Attach the container mc to the stage
    addChild(container);
    
    firstEdit();
}

```

The error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at Adsız\_02\_25\_fla::MainTimeline/onNumericStChange()  
at flash.events::EventDispatcher/dispatchEventFunction()  
at flash.events::EventDispatcher/dispatchEvent()  
at fl.controls::NumericStepper/setValue()  
at fl.controls::NumericStepper/stepperPressHandler()  
at flash.events::EventDispatcher/dispatchEventFunction()  
at flash.events::EventDispatcher/dispatchEvent()  
at fl.controls::BaseButton/startPress()  
at fl.controls::BaseButton/mouseEventHandler()
