# Deleting a display object from within itself

**URL:** <https://forum.kirupa.com/t/deleting-a-display-object-from-within-itself/285829>\
**Category:** flash\
**Created:** [April 7, 2009, 2:38am UTC](https://forum.kirupa.com/t/deleting-a-display-object-from-within-itself/285829 "2009-04-07T02:38:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![baggins825](https://avatars.discourse-cdn.com/v4/letter/b/c68b51/32.png) [@baggins825](https://forum.kirupa.com/u/baggins825)\
**Post date:** [April 7, 2009, 2:38am UTC](https://forum.kirupa.com/t/deleting-a-display-object-from-within-itself/285829/1 "2009-04-07T02:38:01Z")

</div>

Hi all, im making a game and it has enemies randomly spawning at the top of the screen going down to the bottom, so far it all works fine, except for when i try to remove them when they reach the bottom of the screen I get this error

```auto

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
    at flash.display::DisplayObjectContainer/removeChild()
    at spaceavoider/deleteenemy()[/Users/bobbymoranville/Desktop/space avoider/spaceavoiderclasses/spaceavoider.as:135]
    at enemythree/garbagecollect()[/Users/bobbymoranville/Desktop/space avoider/spaceavoiderclasses/enemyone.as:43]
    at enemythree/updatemove()[/Users/bobbymoranville/Desktop/space avoider/spaceavoiderclasses/enemyone.as:37]

```

I have tried every route to fixing this that i can think of but none so far has worked, any suggestions would be greatly apprieciated. :top\_hat:  
P.S. There are fourteen separate classes for the enemies, but they are all similar to the one i attached.
