# Removing e.target from stage

**URL:** <https://forum.kirupa.com/t/removing-e-target-from-stage/290128>\
**Category:** flash\
**Created:** [June 10, 2009, 4:24am UTC](https://forum.kirupa.com/t/removing-e-target-from-stage/290128 "2009-06-10T04:24:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stubbs](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@Stubbs](https://forum.kirupa.com/u/Stubbs)\
**Post date:** [June 10, 2009, 4:24am UTC](https://forum.kirupa.com/t/removing-e-target-from-stage/290128/1 "2009-06-10T04:24:49Z")

</div>

I’ve got a project with a bunch of stuff floating around the screen (enter\_frame moves them all around). I instantiate them with one function, and I want to have them removed in a separate function (all timeline code, no .as files). I want them to remove themselves after floating 500 px off screen. Here are the two I’ve tried:

for (var i:int = 0; i \< this.numChildren - 1; i++)  
{

```
            if ((getChildAt(i).x &lt; -500 ||
                              getChildAt(i).x &gt; stage.stageWidth + 500 || 
                              getChildAt(i).y &lt; -500 || 
                              getChildAt(i).y &gt; stage.stageHeight + 500))
            {
            removeChildAt(i);
            trace(this.numChildren);
            }
            
        }

```

This one works for a percentage of the items. (in same function as instantiation)

function fadeAway(e:Event):void  
{  
e.target.alpha \*= 0.98;  
if (same as above [if more than 500 px off screen])  
{  
e.target.parent.removeChild(e.target);  
}  
}

I tried both this and e.currentTarget. One threw errors and the other did nothing. Is this the standard way to remove children? If not, what is the “correct” way? Thanks.
