# Help with enemy MCs!

**URL:** <https://forum.kirupa.com/t/help-with-enemy-mcs/321418>\
**Category:** flash\
**Created:** [April 19, 2011, 1:50pm UTC](https://forum.kirupa.com/t/help-with-enemy-mcs/321418 "2011-04-19T13:50:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marya2900](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@Marya2900](https://forum.kirupa.com/u/Marya2900)\
**Post date:** [April 19, 2011, 1:50pm UTC](https://forum.kirupa.com/t/help-with-enemy-mcs/321418/1 "2011-04-19T13:50:58Z")

</div>

Hi! So, I have this code for a game I am creating in my digital imaging class. This is the code I am using on my scene which will have the first level of gameplay. Here’s the problem, when I go to the next scene, the enemies that are falling from the top of the screen continue on, past the next level and onto the winning, losing, and main screen. I was told it had something to do with the \_root. , but I have no idea! Any help will be greatly appreciated! Thanks.

```php
 i = 0;
enemies = [5];
 
spawnEnemy = function(){
 _root.attachMovie("enemy", "enemy"+i, _root.getNextHighestDepth());
 _root["enemy"+i]._x = random(Stage.width);
 _root["enemy"+i]._y = 0;
 enemies.push("enemy"+i);
 
 _root["enemy"+i].onEnterFrame = function(){
  this._y += 3;
  if(this._y > Stage.height){
   for(e = 0; e < _root.enemies.length; e++){
    if(_root.enemies[e] == this._name){
     _root.enemies.splice(e, 1);
    }
   }
 
   this.removeMovieClip();
  }
 }
 
 i++;
}
 
enemy_interval = setInterval(spawnEnemy, 2000); 

```
