# Prevent duplicate mc

**URL:** https://forum.kirupa.com/t/prevent-duplicate-mc/16033
**Category:** Uncategorized
**Created:** [March 20, 2003, 10:33am UTC](https://forum.kirupa.com/t/prevent-duplicate-mc/16033 "2003-03-20T10:33:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mitchr](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@mitchr](https://forum.kirupa.com/u/mitchr)
#### Post date: [March 20, 2003, 10:33am UTC](https://forum.kirupa.com/t/prevent-duplicate-mc/16033/1 "2003-03-20T10:33:47Z")

</div>

Hello,

I followed this tutorial [http://www.kirupa.com/developer/actionscript/swapdepth.htm](http://www.kirupa.com/developer/actionscript/swapdepth.htm)  
and added buttons to attach mc when pressed.

How do I prevent a duplicate movieclip instance to be created when a button is pressed, after swapdepth is changed.

// button code  
on (release) {   
\_root.attachMovie(“green”, “green1”, 0);  
green1.\_x = 300;  
green1.\_y = 100;  
}

// swapdepth code:  
on (press, release, dragOver, dragOut) {  
\_root.x += 2;  
\_root.green1.swapDepths(\_root.x);

thanks,

Mitch:crazy:
