# Strange behaving swapDepths

**URL:** <https://forum.kirupa.com/t/strange-behaving-swapdepths/202035>\
**Category:** flash\
**Created:** [September 27, 2006, 6:57am UTC](https://forum.kirupa.com/t/strange-behaving-swapdepths/202035 "2006-09-27T06:57:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Blowfish](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/blowfish/32/744_2.png) [@Blowfish](https://forum.kirupa.com/u/Blowfish)\
**Post date:** [September 27, 2006, 6:57am UTC](https://forum.kirupa.com/t/strange-behaving-swapdepths/202035/1 "2006-09-27T06:57:06Z")

</div>

Iw been playing around with the swapDepths tutorial here on Kirupa, and i got it to work fine. But i got some really strange bug when i wanted to move forward a frame. I will explain:

I have a MC called button \> in that MC theres 3 small MC´s called pink, green, blue and each contains a button with a rollOver effect.  
The 3 MC´s are placed in frame one of the MC button. But here comes the strange part:

I want to make a second frame where one of the 3 buttons is _locked_ in its rollOver mode, no biggy, i just made it into a flash vector gfx and put it in a layer over the buttons.  
But here is where the MC´s becomes very strange. I have this syntax on all the buttons in fram 1:

```php
 
on (rollOver) {
_root.x +=2;
_root.button.MCname.swapDepths(_root.x);
}

```

And i also have

```php
 
on (press) {
_root.button.gotoAndStop(2);
}

```

on the first button just to see if my ide works. But when i press the button and jump to frame 2 the middle button dissapears and the first button stays in place even tho i have removed it from the frame???

So my question is, how can u solve this AND is there a better way? Like make a if() statment that handles the button MC´s instead of changing frames?

And one more thing \> if i want an object to stay on top EVEN tho im useing the swapDepths synstax, how do i need 2 to? Since placing a item in a higher layer dosnt work…

Hope theres someone that can help me…  
(file is attached)
