Jump to content

Scrollbar


krzychu89
 Share

Recommended Posts

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).

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...