1 person found this helpful
I would use ActionScript to do this. Here are steps I would suggest:
1. Add parent components in mxml and give them all id's
2. Write ActionScript that adds items to the components (setters and getters for your dataSource and viewPort).
3. Determine the size of component that causes the scroll bar to appear.
4. If the size of the child component is > the size that triggers the scroll bar, id.paddingRight = whatever, else paddingRight = somethingElse.
Of course I have not actually tested this. But, with MXML, there is always a way around so if this does not work, I would next try making a form (or group) that is dynamically sized based on the content that is to be added, adding all the content to that and then adding the form to the scroller.
I am not 100% sure, but couldnt you just re-skin the spark Scroller, and adjust the padding in the new skin?
try it...go to FILE -> NEW -> MXML Skin...in host component section, specify spark Scroller. that will generate the default skin for spark Scroller.
then you can modify that skin and add your padding there, and reference the new skinClass from spark Scroller.
This would allow padding inside of the Scroller component when it is visible.
Changing the position of the scrollbars in the Scroller component is kind of tricky.
As mentioned earlier you could custom skin the Scroller, but you would need to write a custom ScrollerLayout to control the position of the scrollbars.
You might want to look at the Scroller.minViewportInset property:
Otherwise you might be better off not using a Scroller component but rather hooking up individual HScrollBar and VScrollBar components yourself:
I was just trying to do the same thing. And I thought this would be simple...
Ok so minViewportInset doesn't work. my v scroll bar is about 20 px width and If I set this property to 50px the viewport gets smaller by 50 px from all sides when there is no scroller visible. And when it is visible it's located on the same spot where it would be if you had minViewportInset="1";
So this is like a permanent not depending on the scroller visibility condition.
What I need is simply as the guy who posted this post. When there is no scroller - full size viewport, when there is I want 10px padding for my text.
Shongrunder could you tell if there is some developement on this matter, I see this topic is from long time ago. If no then what should I do:
1) scrollerLayout or 2) individual VScrollBar. I need the easiest solution
Also if the guy who posted this question found a good work around this, please share it
@FM_Flame - This is probably not trivial to implement via a custom ScrollerLayout because dealing with adding and removing scrollbars automatically can get very tricky.
An example: deciding that the vertical scroll bar should be added might change the width of the viewport which might in turn cause the height of the viewport to change which means that a a horizontal scroll bar might need to be added. These kinds of situations can sometimes lead to looping. If you do want to take this path check out the code in ScrollerLayout that protects against this (see ScrollerLayout.invalidationCount and how it's used in updateDisplayList).
I would guess that it might be easier to hook up your own scrollbars. And probably easier if your use case is only one scrollbar rather than two.
If you think this is a common use case please file an enhancement request with more details at http://bugs.adobe.com/jira/
Hey, I was looking for a solution to this also but I realized that this isn't really needed at all.
just pad the content in the group thats in the scroller.
In some cases you can pad the content from all sides, then you will have that gap between the content and the VScrollBar, but also you will have a gap between the content and the left side of the Scroller. If you pad the content only from the right side, then you will have a gap only between the content and the VScrollBar, but if it is not visible, you will have no gaps for every other side of the Scroller, except for the right.
So what you say doesn't really solve the problem, cause the problem is to only add gap between the VScrollBar and the content when the VScrollBar is visible.
I took the easy way out and just made the scrollbar be visible all the time, even when there's not enough content to be scrolled. So the layout is static.
Although it is an old post here the simpliest solution:
Add a custom skin for the scroller,
add to that a custom skin for the scroll bar,
add to the track and thumb the spacing you want. For example left="5".
This will result that there are 5 pixels spacing between the content and the vertical scrollbar.