Get $500+ of the best After Effects files, video templates and music for only $20!
videos

Create a Fully Customizable Scrollbar in Flash

In this tutorial you’ll learn how to create a customizable scrollbar in Flash. The scrollbar will move targeted assets from left to right smoothly and would integrate well with a simple image gallery. Shane uses Flash CS4 but the technique is also compatible with CS3.

Preview

View Screencast

Get the Flash Player to see this player.

Tags: Videos
Add Comment

Discussion 98 Comments

Comment Page 1 of 21 2
  1. Nick Post says:

    Nice!! ;)

    First!!!! :D

  2. tobi says:

    great tutorial !
    and I want you icon set ! :D

  3. b18269 says:

    add easing?

  4. Excactly what i was looking for. Thanks! ;)

  5. txitxarrillo says:

    Magnífico!!!

    Segundo!!!

    ;)

  6. Martijn says:

    Nice Tut.

    Argh Second :(

  7. Adrien "zik" says:

    Nice tutorial !

    Thanks Shane.

  8. Alex says:

    You should probably add an event listener for MOUSE_LEAVE (or possibly MOUSE_UP) on the stage so if you release the mouse outside the flash area, the scrollbar won’t be stuck to the x coord of the mouse cursor.

    Otherwise, decent tut.

    • neterhet says:

      l this..

      private function drag(e:MouseEvent):void
      {
      scrollHandle.startDrag(false, bounds);
      scrollHandle.gotoAndStop(2);
      scrollHandle.removeEventListener(MouseEvent.MOUSE_DOWN, drag);
      stage.addEventListener(MouseEvent.MOUSE_UP, stopdrag);

      }
      private function stopdrag(e:MouseEvent):void
      {
      scrollHandle.stopDrag();
      scrollHandle.gotoAndStop(1);
      scrollHandle.addEventListener(MouseEvent.MOUSE_DOWN, drag);
      stage.removeEventListener(MouseEvent.MOUSE_UP, stopdrag);

  9. Adrien says:

    Nice tutorial !

    Thanks shane, hope to see more coming !

  10. Vasu says:

    How do add easing effects with this scroll bar?

  11. sriganesh says:

    its good bubby.
    can i show some first five lines in my site linking/redirect to your full tutorial page.i like to spread the word, i already tweet this.and cos , i cant clearly understand this:
    Copyright & Usage: :) -> You cannot copy whole tutorials, either in English or translated to another language

  12. sriganesh says:

    can i , i need your permission., cos i dont want to ruin anything. i like this site.
    reply me, or any one outside-can we do like this, i have seen many blog tping some text and linkng to the original site. so i also like to spread the word.

  13. JoeK says:

    You neglected to include an AS3 alternative for the AS2 [b]onReleaseOutside[/b]!!

    Otherwise, nicely done.

    I hope I can find some time to create some tutorials, because this is my area of expertise.

  14. Diego SA says:

    A scrollbar! There’s a lot of tuts of scrollbars, but this one is with a perfect design. Congratulations!

  15. Flash Framer says:

    Very clean and simple. Great tut!

  16. MSFX says:

    Nice, but you need to add the MOUSE_UP listener to the stage, not to the scrollbar itself. Some easing would also be nice. Nice tut though :)

  17. Braden Keith says:

    I see that one of the images were removed from the final product that was in the movie… hahaha. This is a great tutorial – I’m excited to be learning Flash!

  18. Diogo Duarte says:

    Slow tut…

    Still nice…but slow

  19. RUGRLN says:

    Could you guys offer a text tut, or low quality tut…not all of us have speeds capable of streaming 258MB Video files..
    Otherwise a fantastic quality tut…shame I need to wait so long to do it..[approx 45-50 mins..]

  20. Tim says:

    There is no easing, why ?
    With a tweening engine you could really enhance the “smoothness” of the scroll.

  21. Philip says:

    you can actually FULLY costumize the built in components for action script 3 – very easy just dubble click on them and change the graphics

  22. henry says:

    great tut keep up the great work!!!

  23. cyberstar says:

    Please next time include the FLA for download. Yeah, little improvement could be done like easing and mouse up function that limits the contril within the scrollbar.

  24. Adel says:

    Great tut.
    thanx alot mate.
    now u’r getting serious guys :) … keep up

  25. noonoo says:

    anyone any idea what would need to be added/changed for easing with TweenMax, please?

    good tutorial !!!

    Thanks in advance…

  26. Hey guys,

    First of all, thanks for the great comments. This was my first ever video tutorial so there are def a few things I will do a but differently next time and with regards to the MOUSE_LEAVE listener, true could of been done and very easy to implement. As for the easing and in reply to noonoo, in the moveBox – enter_frame function you would change the script I have put to:

    TweenMax.to(scrollingContent, 1, {x: -((contentX – startX) + scrollHandle.x) * ((scrollingContent.width – masker.width) / (scrollBar.width – scrollHandle.width))});

    You could then apply any easing that you wish, to the TweenMax tween.

    Thanks and happy Flashing! ;-)

    Shane

  27. noonoo says:

    Thanks so much Shane.

  28. sucreZ says:

    why i can’t watch full tutorial. i just can watch less than 30s…

  29. pike9 says:

    Nice tut, 2Bad it doesn’t work with the scrollwheel.

    ty!

  30. Simon says:

    I’m getting a few errors in my compiler “1013:The private attribute may be used only on class property definitions.”

    any ideas? – bit of a novice/intermediate, but i promise I’ve looked through my code for spelling mistakes :D

  31. krishna says:

    not so nice bcz when u rollout the scrollbar not release

  32. Grant says:

    I followed this tutorial, but i get an error. im not sure what i did wrong.
    it would be great if you posted the code already typed out, i was hard to follow it in the video.
    other than that good video, im new to using action script’s with flash and came here to learn.

  33. Shane Johnson says:
    Author

    I did send the source files to Flash.tutsplus when I submitted the tute, so I’ll ask Skellie to post it here like I thought he would.

    Shane

  34. diane says:

    please do post the code!

  35. lawrence77 says:

    the video is 258MB

  36. Bob says:

    plz post the code. not working here…

  37. OK as Skellie hasn’t replied to me and Flash.tutsplus have not posted my source files here is a link to the files on my server:

    http://blog.ultravisual.co.uk/sourceFiles/video_src_files.zip

    Shane

  38. You will need to have TweenMax in your library paths as I have not included it with the source and I am assuming that you guys already know how to do this, if not look it up on google. The files are also in CS3 so that all can see.

    Shane

  39. As you can now see, |Skellie has posted the source also.

    Shane

  40. Michaël says:

    When I compile the source fla in flash CS3 it gives a few errors.

    ‘Acces of undefined property Tweener’
    ‘Acces of undefined property Tweenmax’
    ‘Definition caurina.transitions:Tweener could not be found.’
    ‘Definition gs:Tweenmax coulc not be found’

    Do I really need Flash CS4 to do this tutorial?

  41. CgBaran Tuts says:

    Great tutorial thanks

  42. laurie says:

    nice tutorial mine din’t move at all tho

    package
    (
    import flash.display.MovieClip;
    import flash.events.events;
    import flash.events.MouseEvent;
    import flash.geom.Rectangle;
    public class main extends MovieClip
    (
    )
    private bound:Rectangle
    private var start:X Number;
    private var content:Namespace;
    public function main() :void
    (
    )
    addEventListener(event.ADDED_TO_STAGE init );
    )
    private function init(e:Event):void
    )
    removeEventListener(event.ADDED_TO_STAGE init);
    scrollHandle.addEventListener(MouseEvent.MOUSE_DOWN, drag);
    startX = scrollHandle.x;
    contentX = scrollingContent.x;
    bounds = new Rectangle(scrollHandle.x. scrollHandle.y,scrollBar.width – (scrollHandle.width. +4),0);
    )
    private function drag(e:MouseEvent);void
    (
    scrollHandle.startDrag(false, bounds);
    scrollHandle.gotoandstop(2);
    scrollHandle.removeEventListener(MouseEvent.MOUSE_DOWN, drag);
    addEventListener(MouseEvent.MOUSE_UP, stopdrag);
    addEventListener (Event.ENTER_FRAME, movebox);
    )
    private function stopdrag(e:MouseEvent):void
    (
    scrollHandle.stopDrag();
    scrollHandle.gotoandstop(1);
    scrollHandle.addEventListener(MouseEvent.MOUSE_DOWN, drag);
    removeEventListener(MouseEvent.MOUSE_UP, stopdrag);
    removeEventListener (Event.ENTER_FRAME, movebox);
    )
    private function moveBox(e:Event):void
    (
    scrollingContent.x = -1 (contentx -startX) + scrollHandle.x) * ((scrollingContent.x.width – masker.width /scrollBar.width – scrollHandle.width));
    )
    )
    )

    ……………. can anyone help tell me what im doing wrong new to flash

  43. Lou says:

    Thanks Shane, I really enjoyed this tutorial and found watching you make mistakes and then correct them was excellent, because I learn’t from them! Would this work for the new mobile phone touch screens eg Nokia 5800 and could you use your finger to flick to next page?

  44. Hi
    laurie…..what are your error messages?
    lou……thanks….errors are part of the game, you can’t type everything perfectly ;-)….with regards to the Nokia 5800 – no as the flash player on that phone is flash lite 3.0 which doesn’t support actionscript 3.0
    Thanks
    Shane

  45. Actually laurie….I can see a lot of errors……
    You’ve closed your class braces at the beginning, bound isn’t declared as a variable, startX is declared incorrectly, your constructor is closed so that nothing else can happen…….also you are using parenthesis () instead of braces {}……check your source against mine in the source files and see where you have gone wrong……
    Shane

  46. Imran says:

    Thanks Shane!!

  47. sarah says:

    Hey I really thought that your tutorial was interesting, but it won’t work and to be honest i know sod all about flash, im currently in my second year at uni and our brief was to design a portfolio for a chosen artist/designer, and i’ve been looking at the screen for too long and i can’t tell what i’ve done wrong for my file not to work :’(. You said about tweener and tweenermax but i have no idea about any of them. I’d be really grateful if you could help, if you could dumb it down because i really am a noob when it comes to flash xD.

    package
    {
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.geom.Rectangle;

    public class Main extends MovieClip
    {
    private var bounds:Rectangle;
    private var startX:Number;
    private var contentX:Number;

    public function Main ():void
    {
    addEventListener(Event.ADDED_TO_STAGE, init);
    }
    private function init(e;Event):void
    {
    removeEventListener(Event.ADDED_TO_STAGE, init);
    scrollHandle.addEventListener(MouseEvent.MOUSE_DOWN, drag);
    startX = scrollHandle.x;
    contentX = scrollingContent.x;
    bounds = new Rectangle(scrollHandle.x, scrollHandle.y, scrollBar.width – (scrollHandle.width + 4), 0);
    }
    private function drag(e:MouseEvent):void
    {
    scrollHandle.startDrag(false, bounds);
    scrollHandle.gotoAndStop(2);
    scrollHandle.removeEventListener(MouseEvent.MOUSE_DOWN, drag);
    addEventListener(MouseEvent.MOUSE_UP, drag);
    addEventListener(Event.ENTER_FRAME, movebox);
    }
    private function stopdrag(e:MouseEvent):void
    {
    scrollHandle.stopDrag();
    scrollHandle.gotoAndStop(1);
    scrollHandle.addEventListener(MouseEvent.MOUSE_DOWN, drag);
    removeEventListener(MouseEvent.MOUSE_UP, stopdrag);
    removeEventListener(Event.ENTER_FRAME, moveBox);
    }
    private function moveBox(e:Event)void
    {
    scrollingContent.x = – ((contentX – startX) + scrollHandle.x) * ((scrollingContent.width – masker.width / (scrollBar.width – scrollHandle.width));

    }
    }

    Thank you! :)

  48. rich says:

    how do you add, MOUSE_LEAVE?

Comment Page 1 of 21 2

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.