tags:

views:

305

answers:

3

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 using horizontalScrollPosition.

What should i do now? Thanks

A: 

Scroll bars will not be displayed when scrollPolicy is turned off.

Amarghosh
I know, But when i turn then off, I cant scroll the contents of the HBOX programmatically. How can i scroll the contents while scrollPolicy is off?
Max
what happens when you set the scrollpolicy? is there any content to be scrolled? `trace(hbox.maxHorizontalScrollPosition)` to see if there is anything to be scrolled at all
Amarghosh
i get 0, flex disables this attribute after turning off horizontal scroll policy
Max
A: 

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

Paul
Thanks Paul, will try it too.
Max
A: 

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;
    }
}
Markus Johnsson
This is great, Thanks :)
Max