15
Jul
2008
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











hi, i found out that ur scrollbar works great! =) thanks. however, how can i add the up n down button for the scrollbar? thanks :)
Hey Ady, Your scrollbar works good! Thanx Mario
i’m glad you find it helpfull :)
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?
can you submit the code so i’ll have a look?
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
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.
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!
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
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
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?
@Bob,
try clicking on the word “here” :)
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
hi,
did you complete the horizontal scrolling version.
if so can u please give me the url of that source to download
thanks
venkat
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.
When I click the link it just refreshes the page? Is this discontinued?
thanls!
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
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
nice work dude, saved me a shit load of work with this.
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!