PDA

View Full Version : Another HitTest Question



Tekademix
March 9th, 2004, 03:48 AM
I have a movie clip placed on my main timeline with the following actions:

onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.nextFrame();
} else {
this.prevFrame();
}
}


This movieclip has a Stop function on frame 1.
Frames 2-16 Contains the Rollover animation.
Frame 17 Contains a Stop Function.
Frames 18-33 Contains the Rollout Animation.
And Frame 34 Contains a Stop Function.

The problem is that the HitTest function is not recognizing the Stop function and Frame 17. So On Rollover, the movie clips plays both the Rollover and Rollout animations rather than just the Rollover. Anyone have a solution to allow the movieclip to play the Rollover Animation on mouseover and the Rollout Animation on Mouseout. Thanx in Advance.

Adam
March 9th, 2004, 04:51 PM
try this:


onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
if (this._currentframe<this._totalframes) {
nextFrame();
}
} else {
if (this._currentframe>1) {
prevFrame();
}
}
}


Adam

DChihorn
March 10th, 2004, 11:53 AM
Ok, I am a complete newbie, so I might not be reading this correctly, but reading your script, here is how I am interpretting it...

Basically, its saying to always be doing something. (ex. if hit is true move right, otherwise move left). The fact that there is a stop on particular frame inside clip doesnt have any affect on the script on the outside.

Example.

I enter your site that has a box sitting on the screen. this box has the mentioned scripts affecting it. The moment I get on your site it starts checking for that hit test. Obviously, we start out as false, so immediately it tries to go to "this.prevFrame();". Here is where I am a newbie and dont know if a movie loops in both directions. That is to say I dont know if a movie trying to back up from the beginning then starts at the end.

Anyway, let's just say that I move my mouse over said object, so now the test =true. It activates internal script with "this.nextFrame();". And it continues in such a pattern as long as the hit test = true. The external script hit test does not care or look at what the internal script (rollover, and rollout) does, it is simply saying hit test = true, so go do the next thing.

And truthfully, the way this reads, even if it did stop, once the hit test was false, it would turn around and play the thing backwards. So, if all you want to do is to undo the rollover change then to solve your problem, you might just take out the second half of your current script

Another simple way to get it to work is use frame tags.

Ex.
onClipEvent (loadFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
gotoandplay ("over");
/* thinking that you cant have a rollout until after you have had a rollover you make the out a nested if */
if (this.hitTest(_root._xmouse, _root._ymouse, false)) {
gotoandplay ("out");
}
}
}

Again, being a newb, not sure if should be a on event loadframe or enterframe.

But, with this, your internal stop message would work.
Just be sure to tag the appropriate frames.