Custom Actionscript 3 Scrollpane Component with OOP
One of cool things about being a Flash Developer is making your own components. With that being said, one of the things that I’ve wanted to make was my own, custom scrollpane.
After numerous hours, I finally did it.
I thought it would be a lot harder to make one, but it wasn’t that hard. It just involved basic Math and logic. The line that makes the content move the way it does it:
_content.y =-( _handler.y*(_content.height/_track.height));
The “_content” is a movieclip of what you want to move. Since you want that to move vertically, you are going to use the y axis, unless you were going to do a horizontal scrollpane, then you would use the x axis. The “_handler” is slider. The content depends on where that slider is on the scrollbar. Next, you want to get the difference in height between the track and the content. To do that, you divide them both. Then you are going to multiply the y location of the handle to give you a number that the content would use to move up and down.