# hitTest

**URL:** <https://forum.kirupa.com/t/hittest/2294>\
**Category:** flash\
**Created:** [April 30, 2002, 2:06am UTC](https://forum.kirupa.com/t/hittest/2294 "2002-04-30T02:06:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 30, 2002, 2:06am UTC](https://forum.kirupa.com/t/hittest/2294/1 "2002-04-30T02:06:30Z")

</div>

Hi, I just worked up an example with scrolling text. The text scrolls up & when you place you mouse over this text clip the text stops scrolling. It works fine but I ran into a question with hitTest. Why does it work backwards. Here’s the code so I may explain

onClipEvent (enterFrame) {  
// get the original y position of this  
y = \_y  
// hitTest to determine if the mouse is over this  
if (this.hitTest(\_root.\_xmouse,\_root.\_ymouse, false)) {  
// do not scroll the clip  
this.\_y = y;

}else{  
// set the value of y  
y = 1  
//subtract y from this.\_y  
this.\_y -= y  
// add 3 to y  
y +=3  
// if the clip travel outside the mask parameters . . .  
if (this.\_y \< 35) {  
// put it back within the mask parameters  
this.\_y = 327  
}  
}  
}

On the hitTest part I actually have to set the test to false for the dependant code to be excuted.

Basically what’s up with hitTest working backwards. I’m going to toss the .fla up at [members.aol.com/webclicku…ngtext.fla](http://members.aol.com/webclickusa/fla/scrollingtext.fla) if you need to see exactly what I mean.

Thank you very much.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 30, 2002, 2:14am UTC](https://forum.kirupa.com/t/hittest/2294/2 "2002-04-30T02:14:33Z")

</div>

Make that:  
[members.aol.com/webclickusa/fla](http://members.aol.com/webclickusa/fla)  
file is called scrollingtext.fla

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 30, 2002, 9:50am UTC](https://forum.kirupa.com/t/hittest/2294/3 "2002-04-30T09:50:31Z")

</div>

I don’t understand what you mean? you want it to scroll when the mouse is over? explain a little more…I looked at the FLA and it looked fine to me. but obvoiusly thats not what you are trying to do…That makes sense, but I am now away from my computer and won’t get back til at least 6pm (6hours from now) I can look at it then.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 30, 2002, 1:29pm UTC](https://forum.kirupa.com/t/hittest/2294/4 "2002-04-30T13:29:50Z")

</div>

Jubba,  
The .fla is working exactly the way I want it to.  
However, I don’t under why 1 part is working.  
When you mouse over the text is should stop scrolling which it does do. However, the only way the work is if I set the hitTest eval. to false. In other words when you mouse over the text the hitTest should be true & the text should stop scrolling. It works in reverse. Am I making any sense?

Thanks again my friend

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 30, 2002, 2:04pm UTC](https://forum.kirupa.com/t/hittest/2294/5 "2002-04-30T14:04:57Z")

</div>

[edited: due to massive stupidity]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 30, 2002, 2:06pm UTC](https://forum.kirupa.com/t/hittest/2294/6 "2002-04-30T14:06:49Z")

</div>

if (this.hitTest(\_root.\_xmouse,\_root.\_ymouse, false)) {  
// do not scroll the clip  
this.\_y = y

this says that when the hitTest is false, the Text does not move, then the else statement says that when the hitTest is true, that the Text does move…thats what I can get from your code.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 30, 2002, 2:56pm UTC](https://forum.kirupa.com/t/hittest/2294/7 "2002-04-30T14:56:47Z")

</div>

onClipEvent (enterFrame) {  
if (!hitTest(\_root.\_xmouse,\_root.\_ymouse)) {  
this.\_y -= 3  
}  
if (this.\_y \< 35) {  
this.\_y = 327  
}  
}

I think this code will do the same thing as your other code, I just made it shorter. By putting the ! in front you are saying that when its false, you want it to move…I didnt’ test it but something like that should work

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 30, 2002, 3:58pm UTC](https://forum.kirupa.com/t/hittest/2294/8 "2002-04-30T15:58:34Z")

</div>

Jubba,  
You are absolutely right, The code says

if (this.hitTest(\_root.\_xmouse,\_root.\_ymouse, false)) {  
this.\_y = y;  
The above means like you said if the mouse pointer is NOT placed over the clip the clip should NOT scroll

Below means if the mouse pointer is placed over  
the clip the clip should scroll

}else{  
// set the value of y  
y = 1  
//subtract y from this.\_y  
this.\_y -= y  
// add 3 to y  
y +=3  
// if the clip travel outside the mask parameter . . .  
if (this.\_y \< 35) {  
// put it back within the mask parameter  
this.\_y = 327  
}  
}  
}  
It works completely backwards. Try download the .fla & playing the movie & you’ll see what I mean. Try changing the hitTest false to true & things get really funky. Sorry for being such a donkey. I wrote this little snippit of code myself & got it to work but I can’t say  
the if part makes much sense. Sorry to beat a dead horse. I just have to understand this.

Thank you.
