title: Adding enemies from array
body: <p>I have an Enemy Class(which holds all the movie clips that are enemies), a Level class(which lists the layout of the levels in an array) and my Main document class(which produces the layout of the levels in tiles). My goal is to have different enemies for each level. </p>
  
  <p>Enemy Class:</p>
  
  <pre><code>private var enemy1:Enemy1 = new Enemy1();
  private var enemy2:Enemy2 = new Enemy2();
  
  public var enemyArray:Array = new Array(enemy1, enemy2);
  </code></pre>
  
  <p>Level Class:</p>
  
  <pre><code>var enemies:Enemy = new Enemy();
  levelStageNumber = 1;
  if (levelStageNumber == 1) { floor1F(); Main.floor = floor1; }
  private function floor1F():void
          {
              floor1 = new Array();
              floor1[0] = [1,1,1,1,1,1,1];
              floor1[1] = [1,1,1,1,1,1,1];
              floor1[2] = [1,1,1,2,1,1,1];
              floor1[3] = [2,1,1,2,1,1,2];
              floor1[4] = [1,1,1,2,1,1,1];
              floor1[5] = [1,1,1,1,1,1,1];
              floor1[6] = [1,1,1,1,1,1,1];
  
              addChild(enemy2.enemyArray[0]);
  
          }
  </code></pre>
  
  <p>Main Class:</p>
  
  <pre><code>public static var floor:Array = []; //for the main class to talk to the level class
  private var level:Level = new Level();
  
  addChild(level);
  
      for (var Y:int=0; Y&lt;floor.length; Y++)
              {
                  for (var X:int=0; X&lt;floor[Y].length; X++)
                  {
                      var cell:MovieClip = new Tile(X,Y);
                      cell.gotoAndStop(floor[Y][X]);
                      cell.x = ((X-Y)*level.tileh)+365;
                      cell.y = ((X+Y)*level.tileh/2)+70;
                      addChild(cell);
                  }
              }
  </code></pre>
  
  <p>Maybe I'm going about this whole setup the wrong way, but I feel there is an easier way to accomplish what I'm doing. So I have 2 problems. First, how can I add the two enemies from the enemyArray? Secondly, the enemy right now appears underneath the tile, probably because the Main class is the one generating the tiles. Is there any way I can somehow get the enemies to be added to the Main class?</p>