PDA

View Full Version : hit test



eyeinfinitude
December 3rd, 2002, 12:50 PM
What is wrong with this AS? I cant get the hittest to work on these buttons which are now movieclips.

onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true))
if (_currentframe>=75) {
gotoAndPlay(91);
} else {
if (_currentframe>=96) {
gotoAndPlay(96);
updateAfterEvent();
}
}

Guig0
December 3rd, 2002, 01:06 PM
...and he missed!


:*(

lostinbeta
December 3rd, 2002, 01:45 PM
Well for one you missed a curly bracket :)

Not sure if that is the whole problem, but I can tell that one right off the bat...


onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
if (_currentframe>=75) {
gotoAndPlay(91);
} else {
if (_currentframe>=96) {
gotoAndPlay(96);
updateAfterEvent();
}
}
}
}

jsk
December 3rd, 2002, 01:52 PM
create an invisible mc and attach it to the mouse using

onClipEvent (mouseMove) {
_x=_root._xmouse
_y=_root._ymouse
updateAfterEvent(mouseMove)
}

give this mc an instance name like "mouseTarget" then use hitTest -

if (this.hitTest(_root.mouseTarget)) { }

lostinbeta
December 3rd, 2002, 01:56 PM
I did this and worked perfect.... so its not the hitTest that is the problem.


onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
trace("over");
} else {
trace("not over");
}
}

lostinbeta
December 3rd, 2002, 01:57 PM
You could try...


onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
if (_currentframe>=75 && _currentframe<=95) {
gotoAndPlay(91);
} else {
if (_currentframe>=96) {
gotoAndPlay(96);
updateAfterEvent();
}
}
}
}

eyeinfinitude
December 3rd, 2002, 04:16 PM
Thanks for replying guys, but the problem continues. Basically what I have is a movie clip that alphas from 0 to 100 on rollover, that part is simple, but I also want it to control an alpha of a 2nd movie clip too. So when I rollover and rollout on that movieclip, it fades itself and another movieclip at the same time. I already achieved this with the rollover and rollout AS, but its not sensitive enough, if i roll my mouse over it too fast then it will be stuck on a state. I thought if I used the hittest, it would make it more sensitive to the mouse, but so far I havent been able to apply the hittest it. I hope you guys understand what I'm trying to do. :-\

lostinbeta
December 3rd, 2002, 05:27 PM
Use AS to tween the alpha instead of a motion tween.

eyeinfinitude
December 3rd, 2002, 05:47 PM
Thats the problem, I dont know how to do that, I wanna use the hittest to control the alphas of both movieclips, but so far no luck...

lostinbeta
December 3rd, 2002, 05:57 PM
I will whip up an example....


::poof::


Wait... which version of Flash?

If it is MX, I can whip up an example, if it is Flash 5, hmmm, I can't help ya there :(

eyeinfinitude
December 3rd, 2002, 06:02 PM
I'm using MX, thank goodness!! thanks Lost! I owe you big time on this cause its for a important project. =)

lostinbeta
December 3rd, 2002, 06:12 PM
Ok, check my attachment :)

I set the original alpha of the rollOver clip to 10 so you can see where you were rolling over to test it, so the animation of it may seem a bit off, but the idea is there.

I hope it was close to what you wanted to do :)

lostinbeta
December 3rd, 2002, 06:17 PM
Wait wait wait.... I noticed a glitch in the last script where if you moused over it real fast over and over it made it invisible.

Try this one :)

eyeinfinitude
December 3rd, 2002, 06:41 PM
crazy lost! thats exactly what i needed, thanks man!! =)

lostinbeta
December 3rd, 2002, 06:42 PM
No problem, always glad to help :)

Especially on important projects :beam: