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 }
Thanks! just what I was looking for!