Flex 3: HBox children Scrolling with buttons
I have an HBox with width=500.
I actually want to add two arrows buttons that will scroll the contents of the HBox. But when I turn HBox's scroll policy to off, I can't scroll it programmatically usinghorizontalScrollPosition
.
What should i do now?开发者_开发问答 Thanks
I've hacked together this custom HBox that you could use. Simply set horizontalScrollPolicy
to either "on" or "auto". I really haven't tested it all that much, works for a simple test I did...
public class CustomHBox extends HBox
{
override public function validateDisplayList():void
{
super.validateDisplayList();
if (horizontalScrollBar)
horizontalScrollBar.visible = false;
}
}
Scroll bars will not be displayed when scrollPolicy is turned off.
I think for what you want, you want to subclass ScrollBar make it look and feel the way you would like, then set it on your Container.horizontalScrollBar
I'm no Flex expert, but this is possible without too much trouble (using Flex SDK 3.2, anyway). You're right - when you turn off the horizontalScrollPolicy
, the maxHorizontalScollPosition
is set to 0, UNLESS you specify both a width
value AND a maxWidth
value. Then, maxHorizontalScrollPosition
will again contain a useable value, and you'll be able to programmatically set the horizontalScrollPosition
.
精彩评论