# removeChild problem

**URL:** <https://forum.kirupa.com/t/removechild-problem/255155>\
**Category:** Uncategorized\
**Created:** [March 19, 2008, 5:05pm UTC](https://forum.kirupa.com/t/removechild-problem/255155 "2008-03-19T17:05:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![daidai](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/daidai/32/3087_2.png) [@daidai](https://forum.kirupa.com/u/daidai)\
**Post date:** [March 19, 2008, 5:05pm UTC](https://forum.kirupa.com/t/removechild-problem/255155/1 "2008-03-19T17:05:47Z")

</div>

I thought I had got the hang of this but no…

```php
package {

    import flash.display.*;
    import flash.events.*;    
    import flash.net.*;
    import flash.text.*;    
        
    public class Test extends Sprite {            
    
    private var _diffClass:aDifferentClass;
    
        public function Test() 
        {
            innit();                        
            stage.addEventListener(MouseEvent.CLICK, changeSomething);
        }    
        private function innit():void
        {
            var _diffClass= new aDifferentClass();
            _diffClass.x = 0;
            _diffClass.y = 0;        
            addChild(_diffClass);

        }                
        private function changeSomething(e:Event):void
        {
            removeChild(_diffClass);
            innit();            
        }
    }
}

```

I want it so that when the stage is clicked, the \_diffClass child which has been added already is deleted and then added again (with different values, but i havent added all that as to make this example simplier). I get the error: Error #2007: Parameter child must be non-null.  
thanks  
dai
