# If hit Test

**URL:** <https://forum.kirupa.com/t/if-hit-test/309939>\
**Category:** Uncategorized\
**Created:** [May 28, 2010, 5:34am UTC](https://forum.kirupa.com/t/if-hit-test/309939 "2010-05-28T05:34:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![experts585](https://avatars.discourse-cdn.com/v4/letter/e/ecae2f/32.png) [@experts585](https://forum.kirupa.com/u/experts585)\
**Post date:** [May 28, 2010, 5:34am UTC](https://forum.kirupa.com/t/if-hit-test/309939/1 "2010-05-28T05:34:03Z")

</div>

Hi can some one help in hitTest

i just wana doo that if mc hit left side it goes right side and if hit right side it goes left side same in up and down

Here is my code  
if(\_root[“leaf”+mycount+" “+mycount1].hitTest(\_root.fly\_mc)){  
var boxX:Number=\_root[“leaf”+mycount+” “+mycount1].\_x;  
var boxY:Number=\_root[“leaf”+mycount+” "+mycount1].\_y;

```
        var RBoxX:Number=fly_mc._x - boxX;
        var RBoxY:Number=fly_mc._y - boxY ;
        
        

        var tweens=new Tween(_root["leaf"+mycount+" "+mycount1],"_x", Strong.easeOut, fly_mc._x, 200, 1, true);
        var tweene=new Tween(_root["leaf"+mycount+" "+mycount1],"_y", Strong.easeOut, fly_mc._y, 0, 1, true);
```
