Dynamic Scrolling Buttons

[kml_flashembed publishmethod=”dynamic” fversion=”9.0.0″ movie=”https://circlecube.com/circlecube/wp-content/uploads/sites/10/2007/04/dynamicscrollingbuttons.swf” width=”550″ height=”400″ targetclass=”flashmovie”]

Get Adobe Flash player

Here’s an example. A dynamic scroll, that changes speed according to your mouse. Here is the code for it as well, I tried to keep it pretty generic, just put this onto a movie clip I named “scroll.” And change the variables to fit your needs. Enjoy, and let me know what you make with it.

Actionscript (as2)

[cc lang=”actionscript” tab_size=”2″ lines=”40″]

onClipEvent(load) {
scrollMovieClipW = this._width – Stage.width;
leftScrollMargin = 175;
rightScrollMargin = 275;
verticalScrollMargin = 250;
//Note: The lower acceleration value the faster the scroll will be.
acceleration = 3;

onClipEvent (enterFrame) {
//to move left
//if mouse is right of 0 (left edge)
if (_root._xmouse >= 0 &&
//if mouse is left of left scroll margin
_root._xmouse <= leftScrollMargin && //if mouse is vertically below green line (over the scroll movie clip) _root._ymouse >= verticalScrollMargin &&
//if the scroll movie clip can still scroll further
_root.scroll._x <= 0) { this._x -= (_root._xmouse - leftScrollMargin) / acceleration; }//to move right else if (_root._xmouse >= rightScrollMargin &&
_root._xmouse <= Stage.width && _root._ymouse >= verticalScrollMargin &&
_root.scroll._x >= -scrollMovieClipW) {
//move right
this._x -= (_root._xmouse – rightScrollMargin) / acceleration;


Download the example file: dynamicScrollingButtons.fla

13 thoughts on “Dynamic Scrolling Buttons

  1. is there someway to make start at one again when it reaches ten PLEASE HELP…lol…i actually need to load images dynamically instead of numbers but for now this could really work well i use a filmstrip that i create i photoshop instead of the colored bar…

  2. Yes totally, there is a way to do that. I’d start by making it dynamic… Then you can wrap the buttons around to the other side once they are off the stage. Or you can put two instances of the ‘colored bar’ side by side and have them wrap around and connect at the seams. It’s a lot like the Scrolling Link List I made, that one is vertical though, I made it dynamic and they wrap around to the end of the list as soon as they are off stage.

  3. Thank you for sharing, I’ve stared at the actionscript for hours. How do I get my clip to stop scrolling off the stage? Yours stops on a dime, mine scrolls and scrolls…..hanging on by my fingernails….. help me…..

  4. Thanks for the code, I’ve been looking for it for a long time!! Unfortunately in my project there’s some problem, similar to Kent, last comment. It would be nice if you can help us.


  5. @Kent &
    look closely at lines 19 – 20 and 28 of the code above and notice the scrollMovieClipW var in line 3. That’s a good hint…
    It looks at the width of the scrolling clip and checks if it’s scrolled that far before letting it move farther. To go left it’s 0 and right it’s -width.

    Not much more I can do without more explanation or actionscript samples… Good luck!

  6. I’ve got it. (smacks self in forehead) A simple oversight, so painfully obvious once I walked away for a few days. I never named the instance of the symbol in the symbol’s properties so there was no way for it to check itself against the stage size. Thanks Evan, you are a Flash god.

  7. OMG, I totally forgot the instance name as well. Working good… my buttons are off, but that’s probably a silly mistake on my part. I will update with link to site when I am done, but that’ll be a while.

  8. Hi,
    Thank you for this, works a treat. I want to be able to make it work on a vertical axis though. What do I change in the AS to make this work?

    Thank you


  9. hey..i was wanting to know how to make multiple instances of this clip. I know that you can just drag more instances of it to the stage but my site is going to have multiple galleries and i just want to change the instance name to something else. When i change the instance name and look in the actionscript i try changing the “scrollMovieClipW” to whatever i named the other one and i get the same problem as kent and ako…any advice?

Comments are closed.