# \[FlashCS3\]Help needed! attachMovie and removeMovieClip

**URL:** <https://forum.kirupa.com/t/flashcs3-help-needed-attachmovie-and-removemovieclip/256581>\
**Category:** flash\
**Created:** [April 4, 2008, 9:30am UTC](https://forum.kirupa.com/t/flashcs3-help-needed-attachmovie-and-removemovieclip/256581 "2008-04-04T09:30:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivanovi](https://avatars.discourse-cdn.com/v4/letter/i/4491bb/32.png) [@ivanovi](https://forum.kirupa.com/u/ivanovi)\
**Post date:** [April 4, 2008, 9:30am UTC](https://forum.kirupa.com/t/flashcs3-help-needed-attachmovie-and-removemovieclip/256581/1 "2008-04-04T09:30:32Z")

</div>

Hi, I have a few buttons, and for each button blick, a new background is displayed. I tried the following code but there is a problem. Can anyone help? THANKSSS!

function displayBrowse()  
{  
var Background:Array = [“CCBackground1”, “CCBackground2”];

\_root.createEmptyMovieClip(“myMCbg\_mc”, \_root.getNextHighestDepth());  
myMCbg\_mc.attachMovie(Background[0], lbl, this.getNextHighestDepth());  
myMCbg\_mc.\_x = 7;  
myMCbg\_mc.\_y = 165;

for(i=0;i\<2;i++)  
{  
\_root.createEmptyMovieClip(“myMCbtn\_mc”, \_root.getNextHighestDepth());  
myMCbtn\_mc.attachMovie(“CCButton”, “browseButton”+i, this.getNextHighestDepth());  
myMCbtn\_mc[“browseButton”+i].\_x = 23 +(100\*i);  
myMCbtn\_mc[“browseButton”+i].\_y = 165;  
myMCbtn\_mc[“browseButton”+i].\_width = 60;  
myMCbtn\_mc[“browseButton”+i].\_height = 25;  
myMCbtn\_mc[“browseButton”+i].label\_txt.text = i;  
myMCbtn\_mc[“browseButton”+i].onPress = function() {  
whichSubMenu = Number(this.\_name.substr(-1, 1));  
removeMovieClip(myMCbg\_mc);  
\_root.createEmptyMovieClip(“myMCbg\_mc”, \_root.getNextHighestDepth());  
myMCbg\_mc.attachMovie(Background[whichSubMenu], lbl, this.getNextHighestDepth());  
myMCbg\_mc.\_x = 7;  
myMCbg\_mc.\_y = 165;  
myMCbg\_mc.swapDepths(myMCbtn\_mc);  
};  
}  
}  
btn\_clear.onPress = function()  
{  
removeMovieClip(myMCbtn\_mc);  
removeMovieClip(myMCbg\_mc);  
}  
btn\_display.onPress = function()  
{  
displayBrowse();  
}
