# MC and hitTest

**URL:** <https://forum.kirupa.com/t/mc-and-hittest/140186>\
**Category:** Uncategorized\
**Created:** [March 9, 2005, 12:16am UTC](https://forum.kirupa.com/t/mc-and-hittest/140186 "2005-03-09T00:16:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![amirag](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/amirag/32/872_2.png) [@amirag](https://forum.kirupa.com/u/amirag)\
**Post date:** [March 9, 2005, 12:16am UTC](https://forum.kirupa.com/t/mc-and-hittest/140186/1 "2005-03-09T00:16:50Z")

</div>

[color=#333399][font=Tahoma]Hi everyone, I want to create a MC which moves until it reaches a certain point then the MC stop and start moves from the beginning … and during its movement if it hitTest another object I want that MC stop moving.[/font][/color]

[color=#333399][font=Tahoma]I write the following code but it didn’t work as supposed, I don’t know why?? Could anyone help me plzzzz?[/font][/color]  
[color=#333399][/color]  
[color=#333399][font=Tahoma][color=#000000][/color]  
[color=#333399][font=Courier New]onClipEvent(enterFrame){[/font][/color]

[color=#333399][font=Courier New]\_root.s1.\_y=+5;[/font][/color]

[color=#333399][/color][color=#333399][font=Courier New]if (num==1){[/font][/color]

[color=#333399][font=Courier New]if (\_root.s2,hitTest(s1)){[/font][/color]

[color=#333399][font=Courier New]\_root.text3=“collision”;[/font][/color]

[color=#333399][font=Courier New]\_root.s1.stop();[/font][/color]

[color=#333399][font=Courier New]}[/font][/color]

[color=#333399][font=Courier New]else{[/font][/color]

[color=#333399][font=Courier New]\_root.s1.\_y+=5;[/font][/color]

[color=#333399][font=Courier New]\_root.text3=“No collision”;[/font][/color]

[color=#333399][font=Courier New]}[/font][/color]

[color=#333399][font=Courier New]}[/font][/color]

[color=#333399][font=Courier New]else {[/font][/color]

[color=#333399][font=Courier New]if(num==2){[/font][/color]

[color=#333399][font=Courier New]\_root.s1.\_x=0;[/font][/color]

[color=#333399][/color][color=#333399][font=Courier New]\_root.s1.\_y=0;[/font][/color]

[color=#333399][font=Courier New]\_root.s1.\_y+=5;[/font][/color]

[color=#333399][/color][color=#333399][font=Courier New]}[/font][/color]

[color=#333399][font=Courier New]}[/font][/color]

[color=#333399][font=Courier New]if(\_root.s2,hitTest(block)){[/font][/color]

[color=#333399][font=Courier New]num=1;[/font][/color]

[color=#333399][font=Courier New]\_root.text4=“blocked”;[/font][/color]

[color=#333399][font=Courier New]\_root.s1.\_y=+5;[/font][/color]

[color=#333399][font=Courier New]}[/font][/color]

[color=#333399][font=Courier New]else{[/font][/color]

[color=#333399][font=Courier New]num=2;[/font][/color]

[color=#333399][font=Courier New]\_root.text4=“not blocked”;[/font][/color]

[color=#333399][font=Courier New]\_root.s1.\_y=+5;[/font][/color]

[color=#333399][font=Courier New]}[/font][/color]

[color=#333399][font=Courier New]}[/font][/color]

[color=#333399][font=Tahoma]=) [/font][/color]

[/font][/color]
