Detecting when the root directory changes on a FileSystemTree in Adobe AIR

by Peter deHaan on December 13, 2008 · 0 comments

in FileSystemTree

In a previous example, “Setting the root directory on a FileSystemTree control in Adobe AIR”, we saw how you could set the root directory on a FileSystemTree control by setting the directory property to a File object.

The following example shows how you can detect when the directory property changes on an Adobe AIR FileSystemTree control by listening for the directoryChange event.

Full code after the jump.

<?xml version="1.0" encoding="utf-8"?>
<!-- http://airexamples.com/2008/12/13/detecting-when-the-root-directory-changes-on-a-filesystemtree-in-adobe-air/ -->
<mx:WindowedApplication name="FileSystemTree_directoryChange_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle">
 
    <mx:ApplicationControlBar dock="true">
        <mx:Label text="directory:" />
        <mx:ComboBox id="comboBox" toolTip="{comboBox.selectedItem.data.nativePath}">
                <mx:dataProvider>
                    <mx:Object label="FileSystemTree.COMPUTER"
                            data="{FileSystemTree.COMPUTER}" />
                    <mx:Object label="File.applicationDirectory"
                            data="{File.applicationDirectory}" />
                    <mx:Object label="File.applicationStorageDirectory"
                            data="{File.applicationStorageDirectory}" />
                    <mx:Object label="File.desktopDirectory"
                            data="{File.desktopDirectory}" />
                    <mx:Object label="File.documentsDirectory"
                            data="{File.documentsDirectory}" />
                    <mx:Object label="File.userDirectory"
                            data="{File.userDirectory}" />
                </mx:dataProvider>
            </mx:ComboBox>
    </mx:ApplicationControlBar>
 
    <mx:FileSystemTree id="tree"
            directory="{comboBox.selectedItem.data}"
            enabled="{tree.dataProvider.length > 0}"
            width="100%"
            height="100%"
            directoryChange="application.status = event.file.nativePath;" />
 
</mx:WindowedApplication>

{ 0 comments… add one now }

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: