# Animation to move with mouse movement?

**URL:** <https://forum.kirupa.com/t/animation-to-move-with-mouse-movement/35166>\
**Category:** Uncategorized\
**Created:** [November 11, 2003, 4:44am UTC](https://forum.kirupa.com/t/animation-to-move-with-mouse-movement/35166 "2003-11-11T04:44:10Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mariam](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@mariam](https://forum.kirupa.com/u/mariam)\
**Post date:** [November 11, 2003, 4:44am UTC](https://forum.kirupa.com/t/animation-to-move-with-mouse-movement/35166/1 "2003-11-11T04:44:10Z")

</div>

How can i move an animation backward and forward with the movement of the mouse on the x axis?  
all of the mouse trailers etc move an object which is linked to the mouse. however i don’t want my movie clip to move around the screen.  
I have an animation of a wave form which I’ve animated to look as if the wave is increasing and decreasing, ie its amplification. I’d like to move this animation with a mouse movement. ie move your mouse to the left and the wave form increases. move your mouse to the right and the wave form decreases.

I have made an attempt. but it is very clunky and the link with the mouse isn’t exact. the animation of wave form moves only if the mouse moves to one side or the other. it’s not instant, like the infinite menu.  
any ideas how to do this?

here is my clunky code:

if (\_root.\_xmouse\>=300) {  
\_level0.animation.nextFrame();  
} else {  
\_level0.animation.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:** [November 11, 2003, 4:57am UTC](https://forum.kirupa.com/t/animation-to-move-with-mouse-movement/35166/2 "2003-11-11T04:57:27Z")

</div>

hmmm… looks like its a flaw in your code.  
this is so because you tell it only to go to the next frame if its past the 300 pixle mark and if its not it will indefinatly go back to the first frame;  
i would make it some thing like this (beware its not tested).  
put this on you first frame.  
onMouseMove = funciton(){  
mousedist=\_xmouse-oldXmouse;  
oldXmouse=\_xmouse;  
if(mousedist\>0)\_level0.animation.nextFrame();  
if(mousedist\<0)\_level0.animation.prevFrame();  
};  
go for it but i did this thinking that your animation was a movie clip.

---

<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:** [November 11, 2003, 5:11am UTC](https://forum.kirupa.com/t/animation-to-move-with-mouse-movement/35166/3 "2003-11-11T05:11:30Z")

</div>

It works, fantastic. thanks so much booyaka.  
you’ve saved me another 4 hours fiddling around getting frustrated…  
m

---

<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:** [November 11, 2003, 5:17am UTC](https://forum.kirupa.com/t/animation-to-move-with-mouse-movement/35166/4 "2003-11-11T05:17:26Z")

</div>

heh no problem if you can give me a link so i can see what you made

- and im off.

---

<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:** [November 11, 2003, 5:53am UTC](https://forum.kirupa.com/t/animation-to-move-with-mouse-movement/35166/5 "2003-11-11T05:53:24Z")

</div>

it’s part of a larger site which i’m still working on. which at this address.

[http://thap.sca.usyd.edu.au/2003/mva/~mmiranda/museum\_rumour/](http://thap.sca.usyd.edu.au/2003/mva/%7Emmiranda/museum_rumour/)

you’ll need a broadband connection.  
i’ll be putting up your contribution in about 1 hour. i’m very slow. sorry.  
Look for a button that says \<rumour speed\>  
best m

---

<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:** [November 11, 2003, 6:05am UTC](https://forum.kirupa.com/t/animation-to-move-with-mouse-movement/35166/6 "2003-11-11T06:05:00Z")

</div>

wow your pronjext it preetty cool  
i wish i had as much ambition as you do  
but i only code my only drawing tool is the drawing API  
oh welll.

---

<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:** [November 11, 2003, 6:24am UTC](https://forum.kirupa.com/t/animation-to-move-with-mouse-movement/35166/7 "2003-11-11T06:24:08Z")

</div>

thanx. i’m trying. i wish I could speak actionscript as well as you.  
if you have an url i’ll go haave a peak.  
m

---

<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:** [November 11, 2003, 6:42am UTC](https://forum.kirupa.com/t/animation-to-move-with-mouse-movement/35166/8 "2003-11-11T06:42:09Z")

</div>

[http://www.angelfire.com/art2/booyaka](http://www.angelfire.com/art2/booyaka)  
yep there it is its quite a simple site i change it when im bored or im lonely =/  
srry for my poor english  
-and im off

---

<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:** [November 11, 2003, 8:21am UTC](https://forum.kirupa.com/t/animation-to-move-with-mouse-movement/35166/9 "2003-11-11T08:21:53Z")

</div>

love it.  
m

---

<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:** [November 11, 2003, 8:43am UTC](https://forum.kirupa.com/t/animation-to-move-with-mouse-movement/35166/10 "2003-11-11T08:43:29Z")

</div>

are you studying physics? i’ve been looking at some pretty cool physics sites as part of my research for my museum of rumour.  
[http://www.colorado.edu/physics/2000/index.pl](http://www.colorado.edu/physics/2000/index.pl)

i was trying to do one of their graphs of waves.  
all the best  
m

---

<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:** [November 11, 2003, 11:07pm UTC](https://forum.kirupa.com/t/animation-to-move-with-mouse-movement/35166/11 "2003-11-11T23:07:34Z")

</div>

wow thanks for the link ill read about it later.
