Dynamic Scrolling Buttons

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest 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.

  1. onClipEvent(load) {
  2. //variables
  3. scrollMovieClipW = this._width - Stage.width;
  4. leftScrollMargin = 175;
  5. rightScrollMargin = 275;
  6. verticalScrollMargin = 250;
  7. //Note: The lower acceleration value the faster the scroll will be.
  8. acceleration = 3;
  9. }
  10.  
  11. onClipEvent (enterFrame) {
  12. //to move left
  13. //if mouse is right of 0 (left edge)
  14. if (_root._xmouse >= 0 &&
  15. //if mouse is left of left scroll margin
  16. _root._xmouse <= leftScrollMargin &&
  17. //if mouse is vertically below green line (over the scroll movie clip)
  18. _root._ymouse >= verticalScrollMargin &&
  19. //if the scroll movie clip can still scroll further
  20. _root.scroll._x <= 0) {
  21. this._x -= (_root._xmouse - leftScrollMargin) / acceleration;
  22. }
  23.  
  24. //to move right
  25. else if (_root._xmouse >= rightScrollMargin &&
  26. _root._xmouse <= Stage.width &&
  27. _root._ymouse >= verticalScrollMargin &&
  28. _root.scroll._x >= -scrollMovieClipW) {
  29. //move right
  30. this._x -= (_root._xmouse - rightScrollMargin) / acceleration;
  31. }
  32. }

download the source.

  • del.icio.us
  • Digg
  • Facebook
  • Furl
  • Google
  • LinkedIn
  • Ma.gnolia
  • Mixx
  • MySpace
  • Propeller
  • Reddit
  • StumbleUpon
  • Sphinn
  • Spurl
  • Technorati
  • TwitThis
  • Live
  • YahooMyWeb

Related posts

flashden banner

10 Responses to “ Dynamic Scrolling Buttons ”

  1. http://www.beedigital.net/blog/?p=1755

    This page has been featured on Bee Digital

  2. 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…

  3. 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.

  4. 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…..

  5. 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.

    Thanxxxx!!!!

  6. @Kent &
    @Ako,
    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!

  7. 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.

  8. How can I make the scroll go up and down, instead of left to right?

  9. dear friends,

    how to get html pages into dynamic text tool…kindly answer me

  10. Hi

    Nice work done by you.
    Thankx

Leave a Reply

You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <blockquote cite=""> <code> <em> <strong>