15
Jul
2008

as3 scrollbar – free as3 scroller class written in actionscript 3 (flash)

this is a simple scroller class i wrote that helps me in attaching a scroller to every movie clip i want very easily.

the usage is very simple :

var myScroller = new Scroller(source Movie Clip ,  Width ,  Height , Scroller Face MovieClip , Align );

the scroller uses the tweenlite tweening class that can be found at : http://www.TweenLite.com

at the moment it only support left side positioning and no horizontal scrolling, but it’s really easy to fix the code so it can fit anyones needs. i might do it one day…

anyways you can download the scrollbar component here 

 

http://www.adylevy.com/wp-content/plugins/sociofluid/images/digg_32.png http://www.adylevy.com/wp-content/plugins/sociofluid/images/stumbleupon_32.png http://www.adylevy.com/wp-content/plugins/sociofluid/images/delicious_32.png http://www.adylevy.com/wp-content/plugins/sociofluid/images/furl_32.png http://www.adylevy.com/wp-content/plugins/sociofluid/images/technorati_32.png http://www.adylevy.com/wp-content/plugins/sociofluid/images/google_32.png http://www.adylevy.com/wp-content/plugins/sociofluid/images/myspace_32.png http://www.adylevy.com/wp-content/plugins/sociofluid/images/facebook_32.png http://www.adylevy.com/wp-content/plugins/sociofluid/images/yahoobuzz_32.png http://www.adylevy.com/wp-content/plugins/sociofluid/images/twitter_32.png http://www.adylevy.com/wp-content/plugins/sociofluid/images/meneame_32.png
Posted in Flash Demos, as3

20 comments »

  1. luxmiami said,
    September 4, 2008 @ 6:56 am

    hi, i found out that ur scrollbar works great! =) thanks. however, how can i add the up n down button for the scrollbar? thanks :)

  2. mario said,
    October 28, 2008 @ 1:21 am

    Hey Ady, Your scrollbar works good! Thanx Mario

  3. admin said,
    October 31, 2008 @ 4:46 pm

    i’m glad you find it helpfull :)

  4. ade said,
    December 4, 2008 @ 4:26 pm

    Hi I am trying to add 2 scrollers to the same swf but the second one doesnt seem to work correctly, with the scrollbar becoming huge. Also is it possible to hide these, settign alpha to 0 doesnt seem to effect them?

  5. admin said,
    December 6, 2008 @ 1:49 am

    can you submit the code so i’ll have a look?

  6. ade said,
    December 11, 2008 @ 12:55 am

    HI me again:) I solvedmy initial problem at .4. However i have disocvered another problem. Basically i have a few swfs that all use the scroller class. However, im finding when i go back and forth between them I get an error. Im pretty sure it has to do with the listeners being applied to the stage as it only freaks after ive used the scrollbar. Can you suggest how i can resolve this? My base swf contains the unloading of the movies..I guess i could set some kind of flag to see if the event has been set then kill it?

    Also another thing i have discovered:) Say I have a movieclip that contains dynamically created clips. If i essentially just make a cascading list all works fine. However, when I try to make two colums of clips in the movieclip the scrollbar ceases to function.

    thx for the class thought its a fantastic help

  7. admin said,
    December 16, 2008 @ 10:06 pm

    because actionscript3 doesn’t support a destructor for a class, you need to manually write one yourself.
    i bet unloading swfs dynamicly from your main swf causes memory leaks from the loaded swfs as well…

    you should write a public dispose function in your loaded swf, that will call the dispose function on the scroller(’s) and clear all the memory this swf uses.

    i’d say it will look something like this :

    public function dispose(){
    scroller.dispose();
    scroller=null; // that will cause the scroller class to be collected at the next garbage collection…
    flvplayer.dispose();
    scroller2.dispose();
    gallery.dispose()…. etc
    }

    and then on the scroller class you should add something like :

    public function dispose(){
    if (ScrollerPane.stage.hasEventListener(MouseEvent.MOUSE_UP))
    ScrollerPane.stage.removeEventListener(MouseEvent.MOUSE_UP, StageMouseUP);

    and so on for all listeners you want to release.
    }

    hope it will solve your problems .

    Ady.

  8. FB` said,
    January 12, 2009 @ 5:47 pm

    this hit the spot when i needed a quick light scroller.
    i haven’t extended it to do proper disposal but i did hack it around to add both pane and face as children of the same object and then store that as the instance – because i needed 3 at once – also this way, it’s easy to hide them.
    thanks!

  9. SelfLearner said,
    January 23, 2009 @ 12:56 pm

    Hi,
    nice work, thanks.
    @ade
    I had the same problem with you,
    I’m not sure if I break something but I have solved my problem by changing those lines.

    line 78
    ScrollerPane.stage.addEventListener(MouseEvent.MOUSE_UP, StageMouseUP);

    I have change it to
    ScrollerPane.stage.addEventListener(MouseEvent.MOUSE_UP, ScrollFaceUp);

    it doesnt cause any error now.
    thanks
    selflearner

  10. justin said,
    June 22, 2009 @ 3:41 pm

    Hi,

    Is it possible to add the MyScroller object to another MovieClip?

    For example the following will not work for me:

    var myScroller = new Scroller(myPane, myPane.width, 280, new scrollerFace(),”vertical”);

    panel.addChild(myScroller);

    Cheers

    Justin

  11. Bob said,
    November 4, 2009 @ 9:14 pm

    I can’t figure out how to download the class… Call me an idiot :P

    I click on “anyways you can download the scrollbar component here ”

    but it just takes me to this page. Any help?

  12. Brago said,
    November 7, 2009 @ 12:08 pm

    @Bob,
    try clicking on the word “here” :)

  13. jack said,
    December 13, 2009 @ 12:35 pm

    hi great component is first thing to say!:)

    wondered if someone could help me with one issue. I am setting the scrollbar based a conditional:

    if targetClip height is greater than y then set scrollbar.

    However this target contains elements that can be deleted, so i could really do with being able to keep checking after each item delete to see if the scrollbar is still needed and if not remove it. However when i try and do this i get a coloured box overlaying the targ clip. Which is assume is coming from scroller class.

    any help here would be great!

    thx

    jack

  14. venkat said,
    February 5, 2010 @ 12:03 pm

    hi,
    did you complete the horizontal scrolling version.
    if so can u please give me the url of that source to download

    thanks
    venkat

  15. André Martins said,
    February 19, 2010 @ 1:57 pm

    Congratulations, this is one of the simplest and best made and coded pieces of opensource class I’ve stumble upon in the last few months. Good job.

  16. Mindy said,
    March 31, 2010 @ 9:13 pm

    When I click the link it just refreshes the page? Is this discontinued?

    thanls!

  17. Vini said,
    May 29, 2010 @ 4:37 am

    Hey there, amazing job. Extremly useful.
    Although, i think you may want to calculate FaceSize using this formula:

    ” var FaceSize = (PaneMask.height * PaneMask.height) / ScrollerPane.height; ”

    Someone had any luck with Horizontal scroller? if a do i will post it

  18. Vini said,
    May 29, 2010 @ 5:13 am

    Hey, im sorry about the double post, but i f*** did it, and wanted to share.
    You may download an example here: http://losquehacenweb.com/hscroller.zip

    it’s all Ady´s credit, great job

  19. Ryan said,
    June 17, 2010 @ 3:56 am

    nice work dude, saved me a shit load of work with this.

  20. shaun said,
    June 18, 2010 @ 6:14 am

    I’m adding this scroller to different frames and loading different content in each time.

    I’m removing the scroller content before the playhead goes to my next page/frame like this:

    removeChild(myPane);

    But the scrollerface handle remains on the stage.
    How can I remove the scrollerFace from the stage also?

    Thank you!

Leave a Comment