Programmatically scrolling to a selected node in the FileSystemTree control in Adobe AIR

by Peter deHaan on December 13, 2008 · 1 comment

in FileSystemTree

The following example shows how you can automatically scroll to a node in an Adobe AIR FileSystemTree control by using the openSubdirectory(), findIndex(), and scrollToIndex() methods.

Full code after the jump.

Download FileSystemTree_scrollToIndex_test.zip

<?xml version="1.0" encoding="utf-8"?>
<!-- http://airexamples.com/2008/12/13/programmatically-scrolling-to-a-selected-node-in-the-filesystemtree-control-in-adobe-air/ -->
<mx:WindowedApplication name="FileSystemTree_scrollToIndex_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle">
 
    <mx:Script>
        <![CDATA[
            private function btn_click(evt:Event):void {
                var f:File = File.desktopDirectory;
                tree.openSubdirectory(f.nativePath);
                tree.validateNow();
                var idx:int = tree.findIndex(f.nativePath);
                tree.scrollToIndex(idx);
            }
        ]]>
    </mx:Script>
 
    <mx:ApplicationControlBar dock="true">
        <mx:Button id="btn"
                label="Open desktop directory"
                click="btn_click(event);" />
    </mx:ApplicationControlBar>
 
    <mx:FileSystemTree id="tree"
            width="100%"
            height="100%" />
 
</mx:WindowedApplication>

{ 1 comment… read it below or add one }

1 Pebble 01.26.09 at 2:45 pm

Thanks! just what I was looking for!

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Previous post:

Next post: