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