# Hittest / Swapdepth trouble

**URL:** <https://forum.kirupa.com/t/hittest-swapdepth-trouble/201347>\
**Category:** flash\
**Created:** [September 20, 2006, 5:28pm UTC](https://forum.kirupa.com/t/hittest-swapdepth-trouble/201347 "2006-09-20T17:28:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanontheMoon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/danonthemoon/32/7436_2.png) [@DanontheMoon](https://forum.kirupa.com/u/DanontheMoon)\
**Post date:** [September 20, 2006, 5:28pm UTC](https://forum.kirupa.com/t/hittest-swapdepth-trouble/201347/1 "2006-09-20T17:28:14Z")

</div>

My depths won’t swap! Arrrrr!  
This is an easy one, I’m sure - but I’m still not sure why it won’t work. I’ve got a little earth rotating around a sun, and what I want it to do is go behind the sun. I’ve got it to work by making earth\_mc drop alpha to 0 if it hittests and jump up to 100 if it doesn’t, but it look like crap. Instead, I want the earth\_mc and sol\_mc to swapdepths when they hit and the earth is under a certain size. I know I’m on the right track. What value should I plug in to make it work? here’s my script (with gracious thanks to various tutorial writers).

onClipEvent(load){  
speed=10;  
radius=180;  
xcenter=600;  
ycenter=450;  
zcenter=150  
angle=0;  
fl=200;  
}

onClipEvent(enterFrame){  
\_x=Math.cos(angle\*Math.PI/180)_radius+xcenter;  
\_y=y+ycenter;  
z=Math.sin(angle_Math.PI/180)_radius+zcenter;  
scale=fl/(fl+z);  
\_xscale=\_yscale = scale_100  
angle+=speed;  
if(angle\>359){  
angle-=360;  
}  
if (this, hitTest(this.\_parent.sol\_mc) and \_level0.earth\_mc.scale \<= 0.5) {  
this.\_parent.sol\_mc.x +=2;  
\_level0.earth\_mc.swapDepths(this.\_parent.sol\_mc.x);  
}  
}
