# Animating back and forth on rollover and out! HELP!

**URL:** <https://forum.kirupa.com/t/animating-back-and-forth-on-rollover-and-out-help/24159>\
**Category:** Uncategorized\
**Created:** [June 26, 2003, 6:23pm UTC](https://forum.kirupa.com/t/animating-back-and-forth-on-rollover-and-out-help/24159 "2003-06-26T18:23:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanillaCoke](https://avatars.discourse-cdn.com/v4/letter/v/e5b9ba/32.png) [@vanillaCoke](https://forum.kirupa.com/u/vanillaCoke)\
**Post date:** [June 26, 2003, 6:23pm UTC](https://forum.kirupa.com/t/animating-back-and-forth-on-rollover-and-out-help/24159/1 "2003-06-26T18:23:30Z")

</div>

Hi, i’ve been using this code

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

to animate small buttons back and forth when they are rolled over and off. and it looks great, and works perfectly.

Now i want to have the same action in a movie clip that i have placed on the stage it will fade in and expand when that button is rolled over, and of course reverse its animation if its rolled off of.

how do i get the button with the above code also target a movieclip and make it animate concurrently???

thanks for any help!!!

vanillacoke

---

<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:** [June 26, 2003, 6:30pm UTC](https://forum.kirupa.com/t/animating-back-and-forth-on-rollover-and-out-help/24159/2 "2003-06-26T18:30:34Z")

</div>

You’ll have to use a script similar to this.[AS]onClipEvent (enterFrame) {  
if (this.hitTest(\_root.\_xmouse, \_root.\_ymouse, true)) {  
\_root.myMovieClip.nextFrame();  
} else {  
\_root.myMovieClip.prevFrame();  
}  
}[/AS]  
myMovieClip would be the instance name of the movieclip you’re trying to target.

---

<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:** [June 26, 2003, 6:43pm UTC](https://forum.kirupa.com/t/animating-back-and-forth-on-rollover-and-out-help/24159/3 "2003-06-26T18:43:13Z")

</div>

:thumb: :thumb: :thumb: :thumb: :thumb:

Aces! that did it!

i was missing the (\_root) part btw.

THANKS ALOT!!!

---

<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:** [June 26, 2003, 6:45pm UTC](https://forum.kirupa.com/t/animating-back-and-forth-on-rollover-and-out-help/24159/4 "2003-06-26T18:45:01Z")

</div>

I added \_root because I assumed that the movieclip you’re trying to fade was located on the main timeline. \_root refers to the main timeline.

Well I’m glad it worked. =)
