# Help adding movieclips dynamically onto from a class stage

**URL:** <https://forum.kirupa.com/t/help-adding-movieclips-dynamically-onto-from-a-class-stage/294504>\
**Category:** Uncategorized\
**Created:** [August 15, 2009, 5:14am UTC](https://forum.kirupa.com/t/help-adding-movieclips-dynamically-onto-from-a-class-stage/294504 "2009-08-15T05:14:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![M1KES](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@M1KES](https://forum.kirupa.com/u/M1KES)\
**Post date:** [August 15, 2009, 5:14am UTC](https://forum.kirupa.com/t/help-adding-movieclips-dynamically-onto-from-a-class-stage/294504/1 "2009-08-15T05:14:07Z")

</div>

Hi everyone!

ok. so here’s the thing…i have a class from where i created an array with the time, name, and position of each movieclip data… and wanted it to go through each one and execute at a certain time…  
So i tried something like this:

```auto
package Classes
{
    import flash.display.*;
    import flash.events.*;

    public class Enemy extends MovieClip
    {
        var level1Enemies:Array = [[40,"EnemyType1",400,200],[60,"EnemyType1",200,200]];
        var currentLevel:Number = 1;
        var timeCounter:Number = 0;
        var currentEnemies:Array = [];
            
        public function Enemy()
        {
            this.addEventListener(Event.ENTER_FRAME, startEnemy);
            currentEnemies = new Array().concat(this["level"+currentLevel+"Enemies"]);
        }
        function startEnemy(event:Event)
        {
            
            timeCounter ++;

            if (timeCounter == currentEnemies[0][0])
            {
            addEnemy(currentEnemies[0][1], currentEnemies[0][2], currentEnemies[0][3]);
            currentEnemies.shift;
            }
        }
        
        function addEnemy(enemytype,xpos,ypos)
        {
            var newEnemy:MovieClip;
            newEnemy = new getChildByName(currentEnemies[0][2]);
            newEnemy.y = currentEnemies[0][2];
            newEnemy.x = currentEnemies[0][3];
            addChild(newEnemy);
        }
    }
}

```

the first part works well… but its when i try and add it to the stage that i get confused… i tried something but i think its wrong… can anyone help me? Basicly i want flash to get the array… use index 1 for the name… index 2 for the x position and index 3 for the y position… but all this name referencing in as3 really confuses me…  
Any help would be greatly apreciated…

ps: i have already linked the movieclips on the stage
