Skip to content
Dec 13 /

Setting the root directory on a FileSystemTree control in Adobe AIR

The following example shows how you can set the initial directory for the Adobe AIR FileSystemTree control by setting the directory property to a File object, which in this case is the user’s document’s directory.

Full code after the jump.

<?xml version="1.0" encoding="utf-8"?>
<!-- http://airexamples.com/2008/12/13/setting-the-root-directory-on-a-filesystemtree-control-in-adobe-air/ -->
<mx:WindowedApplication name="FileSystemTree_directory_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        title="{tree.directory.nativePath}">
 
    <mx:FileSystemTree id="tree"
            directory="{File.documentsDirectory}"
            width="100%"
            height="100%" />
 
</mx:WindowedApplication>

2 Comments

leave a comment
  1. zmart / Jan 14 2009

    Hi Peter,

    I am trying to set the custom directory, let’s say “C:\Work”.
    Still trying :(
    I was wondering if you give me some advice how to do that.
    Thanks.

    Code below doesn’t work properly

    [Bindable] private var workDir:File;
    workDir = File("C:\Work");
    <mx:FileSystemTree id="fsTree" directory="{workDir}" width="574" height="144">
  2. zmart / Jan 14 2009

    The solution is found:

    workDir = new File("file:///C:/Work");  // was workDir = File("C:/Work");
Leave a Comment