# Attach and then remove mc's with same button?

**URL:** <https://forum.kirupa.com/t/attach-and-then-remove-mcs-with-same-button/195599>\
**Category:** flash\
**Created:** [August 1, 2006, 8:39pm UTC](https://forum.kirupa.com/t/attach-and-then-remove-mcs-with-same-button/195599 "2006-08-01T20:39:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fingers](https://avatars.discourse-cdn.com/v4/letter/f/dc4da7/32.png) [@Fingers](https://forum.kirupa.com/u/Fingers)\
**Post date:** [August 1, 2006, 8:39pm UTC](https://forum.kirupa.com/t/attach-and-then-remove-mcs-with-same-button/195599/1 "2006-08-01T20:39:45Z")

</div>

I’ve been trying to figure this out all day. What I want to have happen is for the mc’s to be attached to the stage and pushed into an array one at a time, and then, when all of them have been added, to remove them from the stage and slice them from the array one at a time, all using the same button. The sequence should go like this…

1stpress attaches mc0\_mc, pushes it into array  
2nd press attaches mc1\_mc, pushes it into array  
3rd press attaches mc2\_mc pushes it into array  
4th press removes mc2\_mc, slices it from array  
5th press removes mc1\_mc, slices it from array  
6th press removes mc0\_mc, slices it from array  
7th press attaches mc0\_mc, pushes it into array… and so on

The attaching and pushing _seem_ like they are working, but I’m having a lot of trouble figuring out how to set up the remove and slice part, and would appreciate some help.  
[FONT=Arial][SIZE=2]  
[/SIZE][/FONT]

```auto
 
var num:Number = 0;
var myBool:Boolean = true;
var arMcAttached_array:Array = new Array();
btn1_btn.onRelease = function() {
if (myBool == true) {
addMc();
}
if (myBool == false) {
removeMc();
}
};
function addMc() {
if (num == 3) {
myBool = false;
return;
} else {
attachMovie("mc"+num, "mc"+num+"_mc", getNextHighestDepth());
arMcAttached_array.push("mc"+num+"_mc");
trace(num);
trace(arMcAttached_array);
num++;
}
}
function removeMc() {
if (num == 0) {
myBool = true;
addMc();
return;
} else {
// Something like?...
// mc+num+_mc.removeMovieClip();
// arMcAttached_array.slice(num);trace(num);
num--;
trace(num);
trace(arMcAttached_array);
return;
}
}

```

Fingers
