# Function problems

**URL:** <https://forum.kirupa.com/t/function-problems/180040>\
**Category:** Uncategorized\
**Created:** [February 24, 2006, 10:30pm UTC](https://forum.kirupa.com/t/function-problems/180040 "2006-02-24T22:30:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nich](https://avatars.discourse-cdn.com/v4/letter/n/e79b87/32.png) [@Nich](https://forum.kirupa.com/u/Nich)\
**Post date:** [February 24, 2006, 10:30pm UTC](https://forum.kirupa.com/t/function-problems/180040/1 "2006-02-24T22:30:29Z")

</div>

```php

removeEnemies = new function()
{
    x = 0;
    while(x < _root.enemies.length)
    {
        unloadMovie(_root[_root.enemies[x]]);
        x++
    }
    
};

```

```php

onClipEvent(enterFrame)
{
    if(_root.guy.hitTest(this))
    {
        
        removeEnemies();
        
        
        diditwork = true;
        
    }
}

```

I can’t seem to get this to work. What I want is if my character crosses a line, all the enemies are removed. The function is declared in a keyframe on the stage and the hitTest is in a line symbol. The actual function code works outside of the function, so it’s not that. “diditwork” is to test the hitTest.
