dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [f8] Making a scrollbar resize relative to the length of the content

  1. #1
    Senior Member
    Join Date
    Feb 2006
    Location
    Melbourne, Australia
    Posts
    105

    [f8] Making a scrollbar resize relative to the length of the content

    Okay, it seems I'm way too far out of highschool to remember how to do this anymore.

    Basically I have a scrollbar but I want the actual scroller to change size relative to the content loaded, obviously not exceeding the size of the scroll track or becoming smaller.

    these are my base variables.

    Code:
    	var scrollHeight:Number  =  scrollTrack._height;
    	var contentHeight:Number = desc_mc._height+20;
    	var scrollFaceHeight:Number = scrollFace._height;
    	var maskHeight:Number = descmask._height;
    I would be most appreciative of any help, my brain just can't seem to remember these equations at all anymore...
    Natural Cow Design
    Interactive and Digital Multimedia - Identity Development and Branding - Design for Print - Consultation and Stratgegy Development

  2. #2
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472
    If you set it up with proportions, it becomes simple.
    Here's how I would do it:

    first, get the amount that can be seen on the screen at one time (maskHeight)
    now, find it's size with proportion to the entire content area (contentHeight):

    Code:
    var viewRatio:Number = maskHeight/contentHeight
    So now, we want to pretend that the scrolling track represents the entire content area, and the scroller button represents the viewable area, so we can say:

    Code:
    scrollerButtonHeight = scrollHeight*viewRatio
    and that's the height you need.

    The concept is this: if the mask height is half of the content height, our viewRatio would be 50% (0.5)... so that also means we make the height of the button 50% of the scrolling track.

    Another nice thing that comes out of this is that if the viewRatio is >= 1 then we know that the content's size is less than the mask... so you can just hide the scroller.
    Pixelwave Flash-based iPhone framework
    iPhone Games: Flyloop | Freedom Run

    Twitter: Oztune

  3. #3
    Senior Member
    Join Date
    Feb 2006
    Location
    Melbourne, Australia
    Posts
    105
    I forgot to say thanks, that helped alot.

    It's always the math stuff that stumps me in flash, so annoying really... Maybe I should invest in some math texts...
    Natural Cow Design
    Interactive and Digital Multimedia - Identity Development and Branding - Design for Print - Consultation and Stratgegy Development

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center