Prevent duplicate mc

Hello,

I followed this tutorial 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: