# SwapDepths... I'm drowning!

**URL:** <https://forum.kirupa.com/t/swapdepths-im-drowning/225205>\
**Category:** flash\
**Created:** [May 9, 2007, 5:19pm UTC](https://forum.kirupa.com/t/swapdepths-im-drowning/225205 "2007-05-09T17:19:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![haider](https://avatars.discourse-cdn.com/v4/letter/h/48db29/32.png) [@haider](https://forum.kirupa.com/u/haider)\
**Post date:** [May 9, 2007, 5:19pm UTC](https://forum.kirupa.com/t/swapdepths-im-drowning/225205/1 "2007-05-09T17:19:34Z")

</div>

I have a layer with three movieclips on it called

cat1\_mc  
cat2\_mc  
cat3\_mc

I have the playhead jump to f1 (frame 10) when cat1\_mc is clicked and  
f2 (frame 20) when cat2\_mc is clicked and so on.

and the playhead jumps back to f0 (frame0) when the close\_mc movieclip is clicked.

???/

I would like cat1\_mc to be above the others when it is clicked and the playhead arrives at frame 10.

???

From what I understand I’m just supposed to add the line of code  
cat2\_mc.swapDepths(9999);

here is the code on frame 10

* * *

MovieClip.prototype.ease = function(tarx, tary) {  
this.onEnterFrame = function() {  
this.\_x = tarx-(tarx-this.\_x)/1.75;  
this.\_y = tary-(tary-this.\_y)/1.75;  
if (Math.abs(tarx-this.\_x)\<1 && Math.abs(tary-this.\_y)\<1) {  
this.\_x = tarx;  
this.\_y = tary;  
delete this.onEnterFrame;  
}  
};  
};  
cat1\_mc.onEnterFrame = function() {  
cat1\_mc.swapDepths(9999);  
cat1\_mc.ease(500,300);  
cat1\_mc.tween(["\_alpha","\_xscale", “\_yscale”],[100, 500, 250], 1, “easeInOutElastic”)  
};  
close\_mc.onRelease = function() {  
\_root.gotoAndStop(“f0”);  
};

* * *

* * *

This works only the first time when I click on say cat2\_mc … it brings it to the front but then doesn’t scale it back to its original size when i click on the close button…  
…and the frame goes back to frame 0 which contains the code.

cat1\_mc.onRelease = function() {  
\_root.gotoAndStop(“f1”);  
};  
cat2\_mc.onRelease = function() {  
\_root.gotoAndStop(“f2”);  
};  
cat3\_mc.onRelease = function() {  
\_root.gotoAndStop(“f3”);  
};

cat1\_mc.onEnterFrame = function() {  
cat1\_mc.ease(200,200);  
cat1\_mc.tween(["\_alpha","\_xscale", “\_yscale”],[100, 100, 100], 1, “easeOutExpo”)  
};  
cat2\_mc.onEnterFrame = function() {  
cat2\_mc.ease(400,200);  
cat2\_mc.tween(["\_alpha","\_xscale", “\_yscale”],[100, 100, 100], 1, “easeOutExpo”)  
};  
cat3\_mc.onEnterFrame = function() {  
cat3\_mc.ease(600,200);  
cat3\_mc.tween(["\_alpha","\_xscale", “\_yscale”],[100, 100, 100], 1, “easeOutExpo”)  
};

Is there something I’m missing?  
Any help much appreciated and I’ll send you a coke if I can.
