Search code examples
apache-flexactionscript-3flex4mxml

Flex 4 Custom Scroll bar on tree component


I want to customize the scrollbars on a mx|Tree component is Flex 4. I would like to mimic this functionality: http://flexponential.com/2009/10/09/changing-the-position-of-the-scroll-bars-in-a-spark-list/

Any thoughts or reccomendations?


Solution

  • This can work, add your own error checking/styling, but you get the idea:

    <s:VGroup gap="-1">
            <s:Button width="100%" label="Scroll up" click="{tree.verticalScrollPosition--}" />
            <mx:Tree id="tree" labelField="@label" showRoot="false" width="300" height="150"
                     verticalScrollPolicy="off">
                <mx:dataProvider>
                    <fx:XML>
                        <root>
                            <node label="Parent 1">
                                <node label="Child 1" />
                                <node label="Child 2">
                                    <node label="Grandchild 1" />
                                    <node label="Grandchild 2" />
                                </node>
                                <node label="Child 3" />
                                <node label="Child 4" />
                                <node label="Child 5" />
                                <node label="Child 6" />
                                <node label="Child 7" />
                                <node label="Child 8" />
                                <node label="Child 9" />
                            </node>
                        </root>
                    </fx:XML>
                </mx:dataProvider>
            </mx:Tree>
            <s:Button width="100%" label="Scroll Down" click="{tree.verticalScrollPosition++}"/>
        </s:VGroup>