# Help with MocieClips Inside Movie Clips(and Duplicating)

**URL:** https://forum.kirupa.com/t/help-with-mocieclips-inside-movie-clips-and-duplicating/184717
**Category:** programming
**Created:** [April 7, 2006, 3:02am UTC](https://forum.kirupa.com/t/help-with-mocieclips-inside-movie-clips-and-duplicating/184717 "2006-04-07T03:02:35Z")
**Posts on this page:** 3
**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 7, 2006, 3:02am UTC](https://forum.kirupa.com/t/help-with-mocieclips-inside-movie-clips-and-duplicating/184717/1 "2006-04-07T03:02:35Z")

</div>

So I have 2 MovieClips named TreeTop(instance = “treeTop1”) and TreeBottom(instance = “treeBottom1”)

The action script for theyre load assembles them into looking like a single tree

So anyway Im trying to run this code in one of my frames

```auto

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

```

and if i have them normally in the movie it works fine and places randomly generated trees all over the screen

However i need to encapsulate them in a MovieClip so I can Manipulate all the trees together as a single object  
and as soon as i put them into the movie clip they will run theyre own constructors(makes sense) but the duplicatemovieclip code doesnt duplicate them

the movie clip Ive encompassed them in is instance named “TOP\_LAYER”

Im guessing im just missing something fairly easy …but how can i get the trees to duplicate in the MC?

[edit] I tried changing  
treeBottom1.duplicateMovieClip( “treeBottom”+i, i+100 );  
treeTop1.duplicateMovieClip( “treeTop”+i, i+50 );  
to  
\_root.[“TOP\_LAYER”].treeBottom1.duplicateMovieClip( “treeBottom”+i, i+100 );  
\_root[“Top\_Layer”].treeTop1.duplicateMovieClip( “treeTop”+i, i+50 );

unfortunatly that didnt work… ☹

---

<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 7, 2006, 10:44am UTC](https://forum.kirupa.com/t/help-with-mocieclips-inside-movie-clips-and-duplicating/184717/2 "2006-04-07T10:44:57Z")

</div>

the easiest way to go about this is to give them a linkage id, and the to use the \_root.attachMovie(), and you could just say

```auto

var top_layer=_root.createEmptyMovieClip("tl",_root.getNextHighestDepth())
top_layer.attachMovie(/*code in here*/)

```

---

<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 7, 2006, 3:52pm UTC](https://forum.kirupa.com/t/help-with-mocieclips-inside-movie-clips-and-duplicating/184717/3 "2006-04-07T15:52:06Z")

</div>

thanks man 🙂
