# Arg...Frusterated(Dynamicly created MC's)

**URL:** <https://forum.kirupa.com/t/arg-frusterated-dynamicly-created-mcs/184503>\
**Category:** programming\
**Created:** [April 5, 2006, 3:46pm UTC](https://forum.kirupa.com/t/arg-frusterated-dynamicly-created-mcs/184503 "2006-04-05T15:46:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joran420](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joran420/32/2329_2.png) [@joran420](https://forum.kirupa.com/u/joran420)\
**Post date:** [April 5, 2006, 3:46pm UTC](https://forum.kirupa.com/t/arg-frusterated-dynamicly-created-mcs/184503/1 "2006-04-05T15:46:49Z")

</div>

OK so I have a Whole tree (you know where birds like to build nests)

and I have this tree broken into 2 parts the Bottom(wich is gonna hitTest against the character) and the top(which is just a gfx that the player can walk right through(or under))

In the Clips Actions for the Bottom Part I have this

```auto
onClipEvent (load) {
 function reset(){
 this._x=random(550);
 this._y=random(200)+100;
 enemySpeed=random(4)+1;
 }
 reset();
}

```

That randomly Generates a a tree Bottom somewhere on screen as soon as a clip is created(and names them treeBottom1

then in the Actions for the TreeTop I have

```auto
onClipEvent (load) {
    stringtoparse = String(this)
     parsedstring = stringtoparse.split("treeTop")
    thisindex = Number(parsedstring[1]);
    
 this._x=_root["treeBottom"+thisindex]._x-42;
 this._y=_root["treeBottom"+thisindex]._y-85;
 trace("ThisIndex = "+thisindex+" X = "+this._x+" Y = "+this._y)
 
}

```

this gets the instance of the treetop being created and tells it to position its self on top of the tree bottom(that matches the instance)

In my control Layer I have this code to generate the trees

```auto
numTrees=10;
        for (i=2; i<=numTrees; i++){
             treeBottom1.duplicateMovieClip( "treeBottom"+i, i+100 );
            treeTop1.duplicateMovieClip( "treeTop"+i, i+100 );
            trace(i)
        }

```

It Places The tree that is already on the stage(Instance :TreeTop1,TreeBottom1)Randomly perfectly but the second tree it cuts off the bottom corner and all the other 9 trees end up directly on top of the 2nd tree so instead of 10 trees it looks like there are 2 trees

WTF am i doing wrong…please help 🙂

---

<div class="post-metadata">

**Author:** ![joran420](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joran420/32/2329_2.png) [@joran420](https://forum.kirupa.com/u/joran420)\
**Post date:** [April 5, 2006, 9:20pm UTC](https://forum.kirupa.com/t/arg-frusterated-dynamicly-created-mcs/184503/2 "2006-04-05T21:20:42Z")

</div>

bump(and a bit more info)

If i dont do the constructor section on the Treetop it will randomly generate all 10 bottoms and …so i have a feeling it has to do with the treetop

---

<div class="post-metadata">

**Author:** ![bombsledder](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bombsledder](https://forum.kirupa.com/u/bombsledder)\
**Post date:** [April 6, 2006, 12:00am UTC](https://forum.kirupa.com/t/arg-frusterated-dynamicly-created-mcs/184503/3 "2006-04-06T00:00:35Z")

</div>

this sounds like a job or actionscript 2.0 :O, oop im not sure exactly how you have this setup so maybe you could post a .fla and i will fix it for and explain in details since you have a clue what your doing i will help you if your like your choice

---

<div class="post-metadata">

**Author:** ![joran420](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joran420/32/2329_2.png) [@joran420](https://forum.kirupa.com/u/joran420)\
**Post date:** [April 6, 2006, 12:14am UTC](https://forum.kirupa.com/t/arg-frusterated-dynamicly-created-mcs/184503/4 "2006-04-06T00:14:41Z")

</div>

I owuld really like that ill attach the FLA as soon as i get home…its not much atm im just trying to mess around and learn AS by trial and error

edit. hmmm.its too big to attach…can i email it to you or somethign?

---

<div class="post-metadata">

**Author:** ![joran420](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joran420/32/2329_2.png) [@joran420](https://forum.kirupa.com/u/joran420)\
**Post date:** [April 6, 2006, 4:09am UTC](https://forum.kirupa.com/t/arg-frusterated-dynamicly-created-mcs/184503/5 "2006-04-06T04:09:42Z")

</div>

Bah i figured it out…the depth on the duplicate was the same in both top and bottom…didnt realize depths had to be unique
