# Animate forward and backward?...help please!

**URL:** <https://forum.kirupa.com/t/animate-forward-and-backward-help-please/21888>\
**Category:** Uncategorized\
**Created:** [May 27, 2003, 6:40pm UTC](https://forum.kirupa.com/t/animate-forward-and-backward-help-please/21888 "2003-05-27T18:40:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tsavo](https://avatars.discourse-cdn.com/v4/letter/t/7bcc69/32.png) [@tsavo](https://forum.kirupa.com/u/tsavo)\
**Post date:** [May 27, 2003, 6:40pm UTC](https://forum.kirupa.com/t/animate-forward-and-backward-help-please/21888/1 "2003-05-27T18:40:50Z")

</div>

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!

---

<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:** [May 27, 2003, 6:44pm UTC](https://forum.kirupa.com/t/animate-forward-and-backward-help-please/21888/2 "2003-05-27T18:44:12Z")

</div>

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.

---

<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:** [May 27, 2003, 6:53pm UTC](https://forum.kirupa.com/t/animate-forward-and-backward-help-please/21888/3 "2003-05-27T18:53:17Z")

</div>

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:-)

---

<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:** [May 27, 2003, 6:55pm UTC](https://forum.kirupa.com/t/animate-forward-and-backward-help-please/21888/4 "2003-05-27T18:55:41Z")

</div>

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

---

<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:** [May 27, 2003, 7:03pm UTC](https://forum.kirupa.com/t/animate-forward-and-backward-help-please/21888/5 "2003-05-27T19:03:39Z")

</div>

```auto
on (rollOver) {
	_root.mc.onEnterFrame = nextFrame;
}
on (rollOut) {
	_root.mc.onEnterFrame = prevFrame;
}

```

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

```

---

<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:** [May 27, 2003, 7:04pm UTC](https://forum.kirupa.com/t/animate-forward-and-backward-help-please/21888/6 "2003-05-27T19:04:47Z")

</div>

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

---

<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:** [May 27, 2003, 7:12pm UTC](https://forum.kirupa.com/t/animate-forward-and-backward-help-please/21888/7 "2003-05-27T19:12:25Z")

</div>

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

---

<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:** [May 27, 2003, 7:12pm UTC](https://forum.kirupa.com/t/animate-forward-and-backward-help-please/21888/8 "2003-05-27T19:12:55Z")

</div>

you’re welcome. 😉
