Easy way to add scrollbar?


I need to be able to scroll down a page in my application. Currently I am only able to do this with the up/down keys, but then you cannot see whether the page is “scrollable” or not. So I would like to add a scrollbar, which the user is able to slide as well.
I was wondering if there is an easy way to add a scrollbar? Flash is my target.


I use this:

It includes a “com.eclecticdesignstudio.ui.Scrollbar” class, which is used to point at existing art assets.

Here is an example from one project I have, which scrolls a “credits” Sprite that contains a bunch of text:

var scrollbar = new Scrollbar (Scrollbar.VERTICAL, CreditsPage.ScrollTrack, CreditsPage.ScrollHandle);
scrollbar.scroll (0, 0);
scrollbar.minimum = 0;
scrollbar.maximum = -credits.height + (cacheHeight * 0.8);
scrollbar.target = credits;
scrollbar.property = "y";

“ScrollTrack” is an object that is the full height of the scrollbar. This is usually the dark grey area behind the scroll handle. “ScrollHandle” is another graphic, which lives on the scroll track and slides from top-to-bottom. The Scrollbar class supports up and down arrow buttons, but in this case I didn’t use them.

The scroll method is used when you want to force scroll to some place on the scrollbar (it accepts two arguments because this class supports horizontal scrollbars, too)

The minimum and maximum are the values associated with the top and bottom of the scroll. In this case, scrolling to the top, I want the credits.y to be 0, but scroll to the bottom, I want to move credits.y to -credits.height, plus a bit of extra padding at the bottom

That was very helpful.

1 Like