I'm trying to move a movie clip which has my main content in
by having it scroll when a button (the button is independent to the
clip I'm moving) is moused over, so that if the "up" button is
moused over it will slowly move the movieClip in that direction.
At present I have code (attached) that responds to my mouse
being over a button by moving my movieClip (contentArea) unless the
movie clip's x value is already at 0, in which case it stops.
However, it does this all in one go, so it instantly is
setting x to 0.
Does anyone know how I could make this gradual, so say for
every second the mouse is over the scroll area the movie clip would
move a set number of pixels that way? Or am I over complicating
things and there is an easier way to do this? It has to be mouse
over as opposed to clicking as I want it to be intuitive.
yeah, the 'while' event will continue to loop and increment
the value until it reaches the goal the will execute. Instead you
need to use an 'onEnterFrame' event to acheive this. I would also
recommend placeing your codes on an 'actions' layer in the main
timeline as a best practice. so create a new layer on the main
timeline called 'actions' and place the following code:
(ps. of course the value '_x' will scroll the contentArea
horizontally, you may need to use '_y')
(pss. also the instance name should be that of your button, I
have 'up_btn' here, use your instance name)
Does it matter that it will mean a couple of hundred lines of
code on the first frame? I have 8 of those buttons (two for each
direction, one for slow moving one for fast) and also a code to
reposition them if the browser resizes.
no it won't matter, that's really not too much code. However,
you would not have to do that, you could assign the method(s) to
your buttons using an array and a loop. even using a 'speed'
property to use the same method for both fast and slow scrolling,
and a 'direction' property, to tell the method which way to scroll.
as far as the positioning goes, that shouldn't matter to the
operation of the buttons, but it may effect your conditional
statement (to stop the scrolling when necessary in the max
direction) so you may want to use a variable and assign it on