New Object-Oriented Scrollbar Video Tutorial

I just finished uploading a new tutorial to gotoAndLearn() which shows you how to create a smooth-scrolling scrollbar prototype on the timeline. This is part one of a two-part series. The next tutorial will take this timeline prototype and abstract it into several ActionScript 3 classes. This type of animated scroll behavior is very popular on Flash sites nowadays and is a good tool to have in your arsenal.

Enjoy the tutorial!
Lee


Commentary

  1. Good video, thanks, one more tool for my collection, thanks Lee. Best Regards!!

  2. Great new tutorial, lee, can´t wait for the second part.

  3. Mauro says:

    Best tutorial ever! :)

    Nice to see how you can do this in 30 and all of this type of scrolls i saw, allways have like 100 ehehe

    Thanks!

  4. jassa says:

    Great tutorial as usual Lee – looking forward to part two!

  5. Guro says:

    Hi There, Thank you for all your great tutorials lee.

    but in this one why you are not using startDrag?

  6. eme says:

    hey! that was smooth! no more 5 fps tutorials.
    looking forward to part 2!!

  7. umbrella says:

    startDrag is imo deprecated for the usage in scrollbars, it often can cause hick ups if you use the mouse too fast, or whatever reasons (at least thats my humble experience)
    Also due to the tweener class you can set up the time and easing method so that creates this wide range of ways to make this work in a dedicated project.

    The scrollbar isn’t so hard to make, even in oop,
    but what is very nice to see is how this example has been coded, 30 lines. Now that alone is a standout achievement imo.

    very nice Lee!

  8. Adrian says:

    Grate tutorial Lee. I have a suggestion for the second part of this tutorial. Whay don’t you build scrollBar component in this way you could make 2 tutorials in one and it will be much easer to drag a scrollBar for the component panel and see its content to a movieClip on the stage.

  9. @Guro:
    It’s seems that you didn’t watch the tutorial, Lee mentioned because startDrag don’t have the updateEvent

  10. Beebs says:

    I know you mentioned it earlier in this tuturiol, but I wonder if you can make it as 3 part tutorial where the third part is about loading the dynamic content (text or graphic) within content movieclip?

    Thanks a lot for usual great generousity.

  11. Dark Vyper says:

    Cool tutorial. Bring on the next one :)

    @Guro: He explains why he doesn’t use startDrag() in the tutorial.

  12. jun says:

    Like guro i’ll said : Why not use a startDrag() on the mouse_down event ? With a bounder you don’t have to make all those conditions in the thumbMove function ^^.

  13. naxjud says:

    great tutorial
    I love it. I am waiting for the next part.
    thank you very much for everything.

  14. Max says:

    Hi,
    you should have done this a lot sooner! Scrollbars almost brought me to stop scripting ;-) . Nice one, and I think Lees drag solution spits out more accurate Numbers, you read some weird things about the drag class.

  15. Abel says:

    Great tutorial. I’d love to see this expanded with mouse wheel scrolling ability!

  16. lee says:

    Just to recap on why not to use startDrag(). The AS3 implementation does not use updateAfterEvent so the behavior is very sluggish. It was something that I first read about in the ActionScript 3.0 Cookbook. You should avoid using this method.

  17. Raul says:

    wasup lee
    love this tutorial, im learning about AS so basically im a newbie at all this but im learning quick so i hope to see part2 soon. thanks alot Lee, im really owning you all i knwo about AS. you the best

  18. Mux says:

    not working for me :\ flash dont recognise import caurina.transitions.*; code line . what can i do to fix it ?

  19. Daniel says:

    Hello Lee, thanks for this great tutorial. And I’ve add a “MOUSE_WHEEL” event:
    stage.addEventListener(MouseEvent.MOUSE_WHEEL, rodaMouse);

    function rodaMouse(gira:MouseEvent):void {
    sb.thumb.y -= gira.delta * 6;
    if (sb.thumb.y = yMax) {
    sb.thumb.y = yMax;
    }
    var sp:Number = sb.thumb.y / yMax;
    Tweener.addTween(content, {y:(-sp*(content.height-masker.height)), time:1});
    gira.updateAfterEvent();
    }
    Just add this action….

    But I have problem to see the swf file. When I decompile inside the flash cs3, they works fine, very fine. And when I open the swf file, they dont work. I add the class caurina to the same folder of .fla file, and set the path class to in the publish setings. But my swf only works inside the flash cs3. I think the flash dont recognise to the caurina.transitions.
    Help please…
    And thanks in advance

  20. Daniel says:

    I dont know why but when I publish my swf file they works…But in my local machine not…

    Anyway…if you want to see my swf and fla file here is:

    http://www.spdez.com.br/daniel/scroll.swf
    http://www.spdez.com.br/daniel/scroll.zip

  21. louie says:

    hi i did the tutorial, but it didnt work i kept keeping the same error codes

    1084: Syntax error: expecting identifier before leftbrace.
    1084: Syntax error: expecting rightparen before leftbrace.
    1084: Syntax error: expecting rightbrace before leftbrace.
    1083: Syntax error: rightparen is unexpected.

    and its talking about this line

    Tweener.addTween(content. {y:(-sp*content.height-masker .height)).

    can anybody please help me out?

    i would verry appriciate it!

  22. Daniel says:

    {y:(-sp*content.height-masker .height)).

    I think the problem is the “.”:
    See: …height)).
    I think the correct is:
    …height)),

    Tweener.addTween(content, {y:(-sp*(content.height-masker.height)), time:1});

  23. Stanko says:

    Hi there, I have done everthing like you said in the video but my scrollbar wont work and than I have downloaded all sample files and again same problem hapend. Do yu know what is the problem, thanks

  24. Nordscape says:

    Daniel,

    Thanks for posting the correct code. I copy/pasted it and compared the two. I tried ‘everything’ before seeing your post. Lee’s tutorial is great but the QT resolution on my computer cannot tell a period from a comma.

    Also, an earlier problem taught me to change the Publish Settings to output to AS 3, even though I had chosen to create a the file as an AS 3.

    Kindest Regards

  25. Geo says:

    Hi, can anybody help me? I have this compiler errors:

    Line: 1 1172: Definition caurina.transitions could not be found.
    Line:29 1120: Access of undefined property Tweener.

    Thanks

  26. Daniel says:

    Hello Geo,
    You have the Tweener class?
    if you dont here is the link:
    http://code.google.com/p/tweener/
    Just install and set path to class. If still not working try copy a caurina folder to the same folder of your fla…

    Stanko, try to publish in a web site your swf file. I dont know why but to me works inside the flash CS3 or inside a published web site…

  27. Dan says:

    Great tutorial. Only problem I’m having is that the scrollbar pulls the clip in about 100 px too far on the right, then cuts off the left edge by the same amount when pulled back to the left. It seems like the width (on a horizontal version) of the “content” clip isn’t being calculated right. I tried several variations, including sticking with a vertical scroll and copying and pasting the tutorial AS as is, and I get the same problem. I’ve made sure the sb and masker are the same height(vertical)/width(hor), etc. Anyone else come across this, or know if there’s a fundamental error I’m making that would cause this? Thanks.

  28. Daniel says:

    Hy, can you post a fla file? Maybe could be a registration point…

  29. Simon says:

    Hi there! Great tutorial, but I like others am getting the error:

    1120: Access of undefined property Tweener.

  30. antoan3 says:

    Aaaw… I can`t see the video :( when i open the link it says:
    Page Not Found!

  31. Daniel says:

    Hello Simon, you need a Tweener Class.
    http://code.google.com/p/tweener/
    Then compile again

  32. Tracy says:

    Hi! Love your scrollbar. Do you have any tutorials for a horizontal one or is there a simple tweak I could do to the vertical to make it scroll vertically?
    Thanks!

  33. kamal98 says:

    Hey lee small problem when i click on the link above its saying server error.

  34. Andrew Kirk says:

    Lee, thanks for another great tutorial! I have gone through a number of scrollbar tutorials which were much more complicated but did not even achieve what you have accomplished in these 32 lines of code. Nice job.

    [Note: the link to this tutorial is wrong. It should point to http://www.gotoandlearn.com/play?id=71.

    Best!

  35. Tizu says:

    Hi!
    Thank you very match for tutorial.
    It is amazing.
    But some thing is not working.
    your SWF file working perfect.
    But when I publish my swf file don’t work.
    I did it in CS3 & CS4 with 2 & 3 screepting.
    Can enybody Help.
    Thank you very match.

Leave a Comment