# RemoveChild problem

**URL:** <https://forum.kirupa.com/t/removechild-problem/324667>\
**Category:** flash\
**Created:** [September 2, 2011, 2:48am UTC](https://forum.kirupa.com/t/removechild-problem/324667 "2011-09-02T02:48:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sinj\_Raion](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@Sinj\_Raion](https://forum.kirupa.com/u/Sinj_Raion)\
**Post date:** [September 2, 2011, 2:48am UTC](https://forum.kirupa.com/t/removechild-problem/324667/1 "2011-09-02T02:48:39Z")

</div>

I’ve been trying to make a movieClip be able to fire a “bullet,” but so far I haven’t had any luck with removing it. I’ve removed all the unnecessary code:

```auto
function shoot(e:MouseEvent){
    var bullet:shootyThing = new shootyThing()
    addChild(bullet)
    bullet.addEventListener(Event.ENTER_FRAME, moveBullet)
    
}

function moveBullet(e:Event){
    trace("something")
    e.currentTarget.range = e.currentTarget.range - Math.abs(Math.cos(e.currentTarget.myAtan2) * e.currentTarget.velocity);
    e.currentTarget.range = e.currentTarget.range - Math.abs(Math.sin(e.currentTarget.myAtan2) * e.currentTarget.velocity);

    if(e.currentTarget.range <= 0 && e.currentTarget.removed == false){
        e.currentTarget.removed = true
        removeChild(e.currentTarget.bullet)

    }
}

```

In short, when the bullet’s range hits zero, I’m thrown the error:

```php
TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/removeChild()
    at Trigonometry_fla::MainTimeline/moveBullet()

```

I’ve never been able to figure out how adding and removing children works, so if anyone has a solution or a good tutorial it’s welcome. Thanks in advance.

EDIT: Jeez, I just noticed that I never actually said the problem came with removing the bullet. I know removeChild is what’s failing, but I don’t know how to fix it.
