This content has been marked as final. Show 6 replies
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)
Thank you, that solution is perfect, much appreciated.
I'll also remember to stick all my code on the timeline, thanks.
you're welcome :)
it does make it much easier to find, reference, and 'point' to other content within your code.
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 resizing.
Thanks, that sounds really good, although pretty complex. I'll have a sit with it when I have a night off work and try to implement something along those lines.