Moving images frame-by-frame with mouse movement

Hi, I’m new to flash mx, so please help me out in details. thanks.
I have 10 images in 10 frames ( 1 image per frame ). So I’m trying to make the frame to go to the next one when the mouse is moved to the right, and make the frame to go to the prev one when the mouse is moved to the left.
Can someone please help me? I really need to have this done ASAP.
Thanks for all the inputs.

Depends what you mean by when the mouse moves to the left or right?

For example you can have a variable that tests the current x position with the previous x position if it’s greater than zero, go to next frame. If smaller than zero go to previous frame.

If you have problems coding it just let me know :}

What I’m trying to do is, I have 10 images, and these images will create 360 degree view of an object. right now I have “next” and “prev” buttons that will make the frames jump tp the next frame or prev frame. Now instead of using these buttons, I want to have to mouse movement to control the frame directly. Say, when the mouse is moved on x-coordinates, the frames jump to the next or prev one.

If you can give me the script/code for this, I would be realy grateful. I have tried several different kinds of script with no luck. I’m totally new to flash and have no clue how to do this.
THanks for all the help.

It would be best that the animation is setup like the image below …

The code for action stop is just … stop();

The code for action mouse is …

var checker = _xmouse;

this.onEnterFrame = function() {

if((_xmouse - checker) > 1)  {
} else if((_xmouse - checker) < -1){

checker = _xmouse;


Hope that helps :slight_smile:

Thanks so much, you just saved my day :D.
One more thing, when the mouse is moved to the left, the images do go to the prev frame, but when it reaches to the first frame, it stops. Is there a way to make it loop to the last frame after it reaches the first frame?

Thank so much for the help.

you can modify code into that maybe…or something similar if it doesnt work. It might skip at the first frame tho =( (code not tested but you get the idea)

} else if((_xmouse - checker) < -1){
if(_currentframe == 1){

Thanks bobdoe, it works. However, I notice there’s a bug in the code, when i test the movie, the first time it loads (which is frame 1), without even moving the mouse, the frame goes reverse to the last frame ( if(_currentframe == 1){
gotoAndStop(_totalframes) )
and keeps looping without even having to move the mouse. Is there a way to prevent this from going to the last frame at the beginning?

Also, Michael Chen, your code does work, but somehow, everytime the images go to the next frame, it tries to go back to the first frame. so I have to keep moving the mouse to the right to prevent it from going back in reverse. Do you have any idea how to fix this?

Also, is there a way to control the speed of the movement?
I don’t mean to ask so many questions or complain about the code your guys give me. I’m really grateful to have your help.
Thank you very much.

ok, i fixed it, thanks a lot for the help

oh, i still need help with the speed though :smiley:
Does anyone know how to control the speed? like the faster the mouse moves, the faster the frame goes to the next one, and vise versa ?
Thank you.

isnt the code already fast enough? on each mouse movement im expecting a frame change…maybe you can post a preview swf for us.

Note: the speed is effected by the fps. Since I used “this.onEnterFrame”

oh yeah… the speed does affected by the fps… Thank you all for the wonderful help…