Animate forward and backward?...help please!

hi there! I have a small problem.
I have a button. on rollover, I want a mc in another location to animate, not a problem, but when I roll out, I want the mc to animate bacwards. can someone help rewrite this code, I found on flashkit, so it will work with what i am trying to do?:

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

I tried this:

[AS]on (rollOver) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
_root.mc.nextFrame();
} else {
_root.mc.prevFrame();
}
}
[/AS]
but it did’nt work out right…
any help will be much appreciated!
thx!

The second one should work if the movieclip you want to animate is located on the main timeline since _root is added.

If the movieclip is located somewhere else like inside another movieclip then that’s the problem. You’ll need to define the path to that movieclip.

Also make sure that the movieclip you want to animate has a instance name of “mc” which is stated in the second script.

thx for replying! but that is not the prob though… What happens when I use this code, is that the mc animates one frame, and one frame only, everytime I rollover my button an nothing happens when I roll out… Have no idear why…I:-)

post your fla so I can take a look at it when I get home.

on (rollOver) {
	_root.mc.onEnterFrame = nextFrame;
}
on (rollOut) {
	_root.mc.onEnterFrame = prevFrame;
}
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
_root.mc.nextFrame();
} else {
_root.mc.prevFrame();
}
}

lol I must be blind, I can’t believe I missed that and I use hitTest a lot too! shame on me. :stuck_out_tongue:

hey!! thank u guys! that did the trick!!

you’re welcome. :wink: