Hi I am trying to get the mouse movement to control the
motion of a film strip on my screen. I have a series of thumbnail
pictures that I have placed side by side as film strip. I have
converted the film strip to a movie clip. The functionality that I
want to achieve is that the movie clip moves to the right when the
mouse moves to the left and moves to the left when the mouse moves
to the right. I have found out that I can use _xmouse to control
the position of the movie clip, but how can I determine if the
mouse is moving to the left or right.
I also want a slower motion when the mouse I closer to the
centre of the stage, and a faster motion when the mouse is far to
the right or far to the left.
If it should be perfect the motion should ease at the end of
A lot of needs, but if you have some code hint of any of
these requests I would be very pleased.
Well suppose you flash screen y 500 pixels width, then the
middle would be 250. Then you can compare the current _xmouse with
the center of your screen:
var dist = 250 - _root._xmouse;
The dist is the distance between the xmouse and the center of
the screen this distance will be positive when the mouse is right
from the center and negative if it is left from it. This way you
know the side. Besides this distance will give you how far from the
center the mouse is. You can use this value to move the movie clip
one way or another. This value might be too high making the clipo
move to fast. To control this you can multiply the dist value by a
percentage and use it to scroll the strip:
var incx = distance * 0.2;
filmStrip._x += incx;
This way everything will work. Now this brings a whole new
problem. What to do when the strip gets to either end? That is
another new and interesting problem.