# AS2.0 - Dynamically adding and removing movie clips

**URL:** https://forum.kirupa.com/t/as2-0-dynamically-adding-and-removing-movie-clips/280754
**Category:** flash
**Created:** [January 31, 2009, 9:58am UTC](https://forum.kirupa.com/t/as2-0-dynamically-adding-and-removing-movie-clips/280754 "2009-01-31T09:58:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![llmills](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@llmills](https://forum.kirupa.com/u/llmills)
#### Post date: [January 31, 2009, 9:58am UTC](https://forum.kirupa.com/t/as2-0-dynamically-adding-and-removing-movie-clips/280754/1 "2009-01-31T09:58:17Z")

</div>

Hi

I have been looking for a way to swap a movie clips when the user clicks on them.

I could not find a function for swapping them, so I dynamically generate the first one, when the user clicks on it, I remove it and add another clip (hoping to repeat the same process), however, when the second one appears it not allow me to click on it - so that I can do the same again.

Any thoughts? The code is below, and I have attached the flash file for you to take a look at - I am currently working in Flash 8.

A solution would be very much appreciated

```auto
this.attachMovie("MOV_addToBasket","addToBasket_mc",this.getNextHighestDepth());
addToBasket_mc._x = 75
addToBasket_mc._y = 50

addToBasket_mc.onRelease = function(){
    _root.attachMovie("MOV_removeFromBasket","removeFromBasket_mc",this.getNextHighestDepth())
    removeMovieClip(_root.addToBasket_mc)
    removeFromBasket_mc._x = 75
    removeFromBasket_mc._y = 50
}    

removeFromBasket_mc.onRelease = function(){
    _root.attachMovie("MOV_addToBasket","addToBasket_mc",this.getNextHighestDepth())
    removeMovieClip(_root.removeFromBasket_mc)
    addToBasket_mc._x = 75
    addToBasket_mc._y = 50
}

```
