Scrolling movie clip tutorial

Hi.

I have a horizontal movieclip that I want to scroll. I want to use two arrows that I’ve made; one facing left and one facing right. When I click down on the arrows I want the movie clip to continue to scroll till either it gets to the end or till the user releases the arrow. Anyone know any tutorials one how to do this? I’ve found lots of tutorials on sliders and more traditional scrollers but none on what I’m describing. Thanks!

assign an instance name to the movieClip you want to scroll, here ill use ‘clip’,
the actions for the right button:

on(press){
this.onEnterFrame=function(){
speed=10;
rlimit=400;//right limit
if(clip._x<rlimit){
clip._x+=speed;
}}
}
on(release,releaseOutside){
delete onEnterFrame;
}

for the left:

on(press){
this.onEnterFrame=function(){
speed=10;
llimit=-400;//right limit
if(clip._x>llimit){
clip._x-=speed;
}}
}
on(release,releaseOutside){
delete onEnterFrame;
}

Hi! How would the same code work for a vertical movie clip? Would it be, instead of right and left, top and bottom or more like x,y? I hope you could help me out! Thanks!! :slight_smile:

Jen

I believe replacing _x with _y will do the trick :slight_smile:

Hi! Thanks for the help and it seems to be working but for some reason, its not exactly working for me! Could you take a look at these (please ignore the lok of the movie clip, i plan to make a new one which would also have a masked area so half of that wouldn’t be shown):

here’s the swf

and here’s the fla so far

This was my first attempt at trying to come up with my own scroller instead of using the scroll pane component (I plan to be scrolling more then just text, thus the need to scroll a movie clip). ANY help would be greatly appreciated! Thanks!!!

Jen

In your code on the up button you have the movie clip instance name as ‘clip’ instead of ‘stuff’. Change it and it will work.

:hr:

Thanks! Duh on me, i cant believe i missed that! Now I have a new question, now that its scrolling correctly, how do i get it to actually stop scrolling when the user has reached the top or bottom of the clip depending on which way they went? Currently, its just scrolling either way right off the swf. Any ideas on that? Thanks again!!!

Jen

Change your limits. :wink:

:hr:

Thanks for the help! It took me a little to get the right limits, but its working now! :slight_smile: Cool and thanks again!

Jen

Glad you got it worked out. :thumb:

For future reference - I find it very handy to use the properties of your clip instead of straight up numbers. That way it doesn’t matter what you have inside your movieclip or if you change it in the future then you don’t have to recalcuate your limits.

For example, set your lower limit to yourclip._height (the height of the clip). If you clip has it’s registration point at the upper left corner then the upper limit could be the _y position etc. You can also set those properties to a variable (e.g. clipheight = myclip._height) and then use that variable as your limit. Play around with it and remember that the trace() command can be very useful!

:hr:

holy old posts! :huh:
this was probably the last time I used Flash! :lol: