# My god more problems hitTest this time

**URL:** https://forum.kirupa.com/t/my-god-more-problems-hittest-this-time/259569
**Category:** Uncategorized
**Created:** [May 6, 2008, 7:39pm UTC](https://forum.kirupa.com/t/my-god-more-problems-hittest-this-time/259569 "2008-05-06T19:39:25Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![cooldude88](https://avatars.discourse-cdn.com/v4/letter/c/e0b2c6/32.png) [@cooldude88](https://forum.kirupa.com/u/cooldude88)
#### Post date: [May 6, 2008, 7:39pm UTC](https://forum.kirupa.com/t/my-god-more-problems-hittest-this-time/259569/1 "2008-05-06T19:39:25Z")

</div>

ok i know ive posted alot of topics lately but i still need help here ive got prolbems with my game im making check my other posts for a full list but anyways here it is my hit test is acting up if i put it in my main timeline it wont work if i put it on the object only it wont work but if i put the exact same code on them both it does:q: im using flash mx 2004 as2 naturally but i have a short aniamtion before my game so my code is in frame 110. by the way man\_mc is my character floor\_mc is my floor and bottomright\_mc is my bottom right platform im putting up my main code anyone please help i am so confused you have no idea.  
stop();  
up = 20;  
grav = 5;  
left = 5;  
right = 5;  
jump = false;  
onEnterFrame = function () {  
if (jump == true) {  
grav = 8;  
}  
if (Key.isDown(Key.LEFT)) {  
\_root.man\_mc.\_x -= left;  
this.man\_mc.legs\_mc.play();  
this.man\_mc.head\_mc.gotoAndStop(‘left’);  
}  
if (Key.isDown(Key.RIGHT)) {  
\_root.man\_mc.\_x += right;  
this.man\_mc.legs\_mc.play();  
this.man\_mc.head\_mc.gotoAndStop(‘right’);  
}  
if (Key.isDown(Key.UP)) {  
jump = true;  
}  
if (jump == true) {  
up–;  
\_root.man\_mc.\_y -= up;  
}  
if (up\<=0) {  
up = 20;  
jump = false;  
}  
if (\_root.floor\_mc.hitTest(\_root.man\_mc) == true) {  
grav = 0;  
jump = false;  
}  
if (\_root.bottomleft\_mc.hitTest(\_root.man\_mc) == true) {  
grav = 0;  
jump = false;  
}

\_root.man\_mc.\_y += grav;  
};

o ya and sorry bout the script im not sure how to do the actionscript bubbles yet.  
ok heres whats happening now as you know my code wont work but the twist is even an empty comment in my object makes my hitTest work perfectly just an empty comment nothing else please help i am so confused and now even more so.

---

<div class="post-metadata">

### Author: ![cooldude88](https://avatars.discourse-cdn.com/v4/letter/c/e0b2c6/32.png) [@cooldude88](https://forum.kirupa.com/u/cooldude88)
#### Post date: [May 12, 2008, 6:46pm UTC](https://forum.kirupa.com/t/my-god-more-problems-hittest-this-time/259569/2 "2008-05-12T18:46:57Z")

</div>

please if anyone could help i have a dead line coming up on this project and i havnt a clue as to how to solve this problem and the others i posted as well \*\*[U]any [/U]\*\*hep would be greatly appreciated

---

<div class="post-metadata">

### Author: ![pantas](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@pantas](https://forum.kirupa.com/u/pantas)
#### Post date: [May 15, 2008, 11:13am UTC](https://forum.kirupa.com/t/my-god-more-problems-hittest-this-time/259569/3 "2008-05-15T11:13:17Z")

</div>

can you paste a fla?

---

<div class="post-metadata">

### Author: ![JBPresents](https://avatars.discourse-cdn.com/v4/letter/j/bc79bd/32.png) [@JBPresents](https://forum.kirupa.com/u/JBPresents)
#### Post date: [May 15, 2008, 4:51pm UTC](https://forum.kirupa.com/t/my-god-more-problems-hittest-this-time/259569/4 "2008-05-15T16:51:51Z")

</div>

What type of hit test are you trying to perfom?

would a simple point hittest work as good say if your registration point were in the middle of your movie clip  
if(\_root.floor\_mc.hitTest(\_root.man\_mc.\_x,\_root.man\_mc.\_y))

if you need it to land on its feet do something like  
if(\_root.floor\_mc.hitTest(\_root.man\_mc,\_root.man\_mc.\_y+15)){}

[quote=cooldude88;2322745]ok i know ive posted alot of topics lately but i still need help here ive got prolbems with my game im making check my other posts for a full list but anyways here it is my hit test is acting up if i put it in my main timeline it wont work if i put it on the object only it wont work but if i put the exact same code on them both it does:q: im using flash mx 2004 as2 naturally but i have a short aniamtion before my game so my code is in frame 110. by the way man\_mc is my character floor\_mc is my floor and bottomright\_mc is my bottom right platform im putting up my main code anyone please help i am so confused you have no idea.  
stop();  
up = 20;  
grav = 5;  
left = 5;  
right = 5;  
jump = false;  
onEnterFrame = function () {  
if (jump == true) {  
grav = 8;  
}  
if (Key.isDown(Key.LEFT)) {  
\_root.man\_mc.\_x -= left;  
this.man\_mc.legs\_mc.play();  
this.man\_mc.head\_mc.gotoAndStop(‘left’);  
}  
if (Key.isDown(Key.RIGHT)) {  
\_root.man\_mc.\_x += right;  
this.man\_mc.legs\_mc.play();  
this.man\_mc.head\_mc.gotoAndStop(‘right’);  
}  
if (Key.isDown(Key.UP)) {  
jump = true;  
}  
if (jump == true) {  
up–;  
\_root.man\_mc.\_y -= up;  
}  
if (up\<=0) {  
up = 20;  
jump = false;  
}  
if (\_root.floor\_mc.hitTest(\_root.man\_mc) == true) {  
grav = 0;  
jump = false;  
}  
if (\_root.bottomleft\_mc.hitTest(\_root.man\_mc) == true) {  
grav = 0;  
jump = false;  
}

\_root.man\_mc.\_y += grav;  
};

o ya and sorry bout the script im not sure how to do the actionscript bubbles yet.  
ok heres whats happening now as you know my code wont work but the twist is even an empty comment in my object makes my hitTest work perfectly just an empty comment nothing else please help i am so confused and now even more so.[/quote]

---

<div class="post-metadata">

### Author: ![cooldude88](https://avatars.discourse-cdn.com/v4/letter/c/e0b2c6/32.png) [@cooldude88](https://forum.kirupa.com/u/cooldude88)
#### Post date: [May 15, 2008, 6:31pm UTC](https://forum.kirupa.com/t/my-god-more-problems-hittest-this-time/259569/5 "2008-05-15T18:31:19Z")

</div>

ok thanks for the replies to jbpresents ive got him landing properly and everything but the only way my hittests are working are if there is an empty comment on the object its not quite done but i need to get this finished soon and really want to get rid of those empty comments for if i take them out then it fails if i put them in it works and as requested a fla is actually not possible for it is a large file i have an animation before the actual game so i cant upload an fla but you have all of my code. and man\_mc is my charcter, floor\_mc is the main ground, and bottomleft\_mc is my platform on the bottom left. any ideas would be appreciated

---

<div class="post-metadata">

### Author: ![JBPresents](https://avatars.discourse-cdn.com/v4/letter/j/bc79bd/32.png) [@JBPresents](https://forum.kirupa.com/u/JBPresents)
#### Post date: [May 15, 2008, 6:44pm UTC](https://forum.kirupa.com/t/my-god-more-problems-hittest-this-time/259569/6 "2008-05-15T18:44:44Z")

</div>

first in your project save as a seperate fla so you can modify and still have the original

next I would try going through the code line by line chances are there is a ; when there should be a { or there is too many and one of your comments is cancling out the bad one

otherwise meh leave the comments in if it works go with it 🙂

---

<div class="post-metadata">

### Author: ![cooldude88](https://avatars.discourse-cdn.com/v4/letter/c/e0b2c6/32.png) [@cooldude88](https://forum.kirupa.com/u/cooldude88)
#### Post date: [May 15, 2008, 6:46pm UTC](https://forum.kirupa.com/t/my-god-more-problems-hittest-this-time/259569/7 "2008-05-15T18:46:54Z")

</div>

ok i might just try to seperate the part that isnt working a little bit later but if there was a ; instead of a { then wouldnt that make the code fail completly or produce a compiler error
