krzychu89 Posted October 16, 2014 Share Posted October 16, 2014 Hello. How can I do scrollbar like in web pages? Quote Link to comment Share on other sites More sharing options...
Sebi Posted October 19, 2014 Share Posted October 19, 2014 You have to code a scrollbar yourself.Don't worry, it's not too hard. Basically, you have a DisplayObjectContainer and apply a mask to it. The mask is your viewport.Then you need to calculate the height/width of the container. That's the scrollHeight/scrollWidth. Now you need a scrollbar sprite. It's height is viewport.height*viewport.height/scrollHeight.Then you apply a mousedown/mousemove and mouseup handler to the scrollbar to make a drag handler. Based on the scrollbars position, you calculate the DisplayObjectContainers position and for performance reasons, hide everything that is not in the viewport. Then you can add all kind of fancy stuff to it (swipe, mousewheel interaction, etc). You can code that whole thing in less than 100-200 lines of code (probably). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.