# Dynamically (I think?) loading Movie Clips onto Stage... Easy Problem needs solving

**URL:** https://forum.kirupa.com/t/dynamically-i-think-loading-movie-clips-onto-stage-easy-problem-needs-solving/306319
**Category:** flash
**Created:** [March 12, 2010, 8:59pm UTC](https://forum.kirupa.com/t/dynamically-i-think-loading-movie-clips-onto-stage-easy-problem-needs-solving/306319 "2010-03-12T20:59:05Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![999chris](https://avatars.discourse-cdn.com/v4/letter/9/f17d59/32.png) [@999chris](https://forum.kirupa.com/u/999chris)
#### Post date: [March 12, 2010, 8:59pm UTC](https://forum.kirupa.com/t/dynamically-i-think-loading-movie-clips-onto-stage-easy-problem-needs-solving/306319/1 "2010-03-12T20:59:05Z")

</div>

Hello Kirupa fans…

I’ve made 2 MovieClips so far… “Terr1” & “Terr2” with the linkages to be exported.

and my script so far is this:

```auto
var landMap:Array = new Array();
landMap = [2,1,1,2,2];

//function to create landscape
function createLand(landAmount):void {
    for (var i=0; i<landAmount; i++) {

        var chosenLand:Number = landMap*;
        var terr = root["Terr" + chosenLand];

        root["piece" + i] = addChild(new terr());
        var thisPiece = root["piece" + i];
        var oldPiece = root["piece" + (i - 1)];

        //moving into the right place
        if (i <= 0) {
            thisPiece.x = 0;

        } else {

            thisPiece.x = (oldPiece.x + oldPiece.width);
        }

        thisPiece.bound.alpha = 0;
        thisPiece.y = stage.stageHeight;

    }

}

//calling create land function
createLand(landMap.length);
stop();

```

so far this works if I replace

```auto
root["piece" + i] = addChild(new terr());

```

with

```auto
root["piece" + i] = addChild(new Terr1())

```

.

but obviously that makes all the pieces “Terr1” I want to define which blocks to use in the “landMap” Array at the top of the code which is [2,1,1,2,2]… So on the display it shows “Terr2”, “Terr1”, “Terr1”, “Terr2”, “Terr2”

I’ve got as far as being able to change a variable “terr” to either “Terr1” or “Terr2” depending on which loop its on. but I cant find a way to do something like \> " addChild(new terr()) "

Hope this makes sense, hope you can help.:cowbell:

My file is attached.
