# Removing dynamically attched movies

**URL:** <https://forum.kirupa.com/t/removing-dynamically-attched-movies/196355>\
**Category:** flash\
**Created:** [August 7, 2006, 9:15pm UTC](https://forum.kirupa.com/t/removing-dynamically-attched-movies/196355 "2006-08-07T21:15:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zaid\_W1red](https://avatars.discourse-cdn.com/v4/letter/z/cab0a1/32.png) [@Zaid\_W1red](https://forum.kirupa.com/u/Zaid_W1red)\
**Post date:** [August 7, 2006, 9:15pm UTC](https://forum.kirupa.com/t/removing-dynamically-attched-movies/196355/1 "2006-08-07T21:15:50Z")

</div>

Hey Guys,  
Im using the following AS to place clips on the stage and to remove them:  
ActionScript Code:  
[FONT=Courier New][LEFT][COLOR=#0000FF]import[/COLOR] mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]Tween[/COLOR];[COLOR=#808080]\*  
\*[/COLOR][COLOR=#000000] **var** [/COLOR] numitems:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#000080]1[/COLOR];  
[COLOR=#000000] **var** [/COLOR] myX:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#0000FF]button[/COLOR].[COLOR=#0000FF]\_x[/COLOR];  
[COLOR=#000000] **var** [/COLOR] [COLOR=#0000FF]moveTo[/COLOR]:[COLOR=#0000FF]Number[/COLOR] = myX-[COLOR=#0000FF]button[/COLOR].[COLOR=#0000FF]\_width[/COLOR];  
[COLOR=#0000FF]button[/COLOR].[COLOR=#0000FF]onRelease[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
numitems++;  
[COLOR=#0000FF]button[/COLOR].[COLOR=#0000FF]attachMovie[/COLOR][COLOR=#000000]([/COLOR][COLOR=#FF0000]“button”[/COLOR], [COLOR=#FF0000]“button”[/COLOR]+numitems+[COLOR=#FF0000]"\_mc"[/COLOR], [COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]getNextHighestDepth[/COLOR]COLOR=#000000[/COLOR], [COLOR=#000000]{[/COLOR][COLOR=#0000FF]\_x[/COLOR]:[COLOR=#0000FF]button[/COLOR].[COLOR=#0000FF]\_width[/COLOR][COLOR=#000000]}[/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#000000]}[/COLOR];  
back.[COLOR=#0000FF]onRelease[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#0000FF]unloadMovie[/COLOR]COLOR=#000000[/COLOR];  
numitems–;  
[COLOR=#0000FF]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
numitems = [COLOR=#000080]1[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR];  
[/LEFT]  
[/FONT]

An example FLA is also attached which should allow you to see my problem.

I can add as many clips as I like and then remove them till I get back down to the button I start with which is great …but as soon as I click and add clips again, I can no longer remove them!

I hope this makes sence…can anyone help??

Zaid
