# Duplicate and attach movie within another movie clip problem

**URL:** <https://forum.kirupa.com/t/duplicate-and-attach-movie-within-another-movie-clip-problem/188991>\
**Category:** Uncategorized\
**Created:** [May 12, 2006, 11:44am UTC](https://forum.kirupa.com/t/duplicate-and-attach-movie-within-another-movie-clip-problem/188991 "2006-05-12T11:44:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AXiAL](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@AXiAL](https://forum.kirupa.com/u/AXiAL)\
**Post date:** [May 12, 2006, 11:44am UTC](https://forum.kirupa.com/t/duplicate-and-attach-movie-within-another-movie-clip-problem/188991/1 "2006-05-12T11:44:57Z")

</div>

I’m having problems duplicating/attaching movie clips within a movie clip.

I have a panel\_MC on stage. I want to be able to dynamically attach several movie clips (essentially they will be buttons) into this panel\_MC. Unfortunately when I use mc.attachMovie() the previous movie clips are overridden…

here is some of my code.

```auto

var noOfIcons:Number = 10; /* 10 for easiness sake.. real number will be determined by a function */
var iconBtnXPos:Number = 0;
	

for (i=1; i<noOfIcons;i++){
	var btnNo:Number = i;
panel.createEmptyMovieClip("container"+btnNo,this.getNextHighestDepth());
whereIsThis = panel["container"+btnNo].attachMovie("iconButton","icon"+btnNo, this.getNextHighestDepth());	
trace("whereIsThis :"+ whereIsThis);
this.panel["container"+btnNo]["icon"+btnNo].iconLabel.iconText.text = btnNo;
this.panel["container"+btnNo]._x = iconBtnXPos;
this.panel["container"+btnNo]["icon"+btnNo].onRelease = iconBtnRelease;
		
iconBtnXPos +=52; //calculate next _x button position
} 

```

Any ideas?
