Skip to content
Dec 14 /

Toggling file extensions on the FileSystemTree control in Adobe AIR

The following example shows how you can toggle file name extensions on the Adobe AIR FileSystemTree control by setting the showExtensions property.

Full code after the jump.

<?xml version="1.0" encoding="utf-8"?>
<!-- http://airexamples.com/2008/12/14/toggling-file-extensions-on-the-filesystemtree-control-in-adobe-air/ -->
<mx:WindowedApplication name="FileSystemTree_showExtensions_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle">
 
    <mx:ApplicationControlBar dock="true">
        <mx:CheckBox id="checkBox"
                label="showExtensions:"
                labelPlacement="left"
                selected="true" />
    </mx:ApplicationControlBar>
 
    <mx:FileSystemTree id="tree"
            showExtensions="{checkBox.selected}"
            width="100%"
            height="100%" />
 
</mx:WindowedApplication>

You can also set the showExtensions property using ActionScript, as seen in the following example:

<?xml version="1.0" encoding="utf-8"?>
<!-- http://airexamples.com/2008/12/14/toggling-file-extensions-on-the-filesystemtree-control-in-adobe-air/ -->
<mx:WindowedApplication name="FileSystemTree_showExtensions_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle">
 
    <mx:ApplicationControlBar dock="true">
        <mx:CheckBox id="checkBox"
                label="showExtensions:"
                labelPlacement="left"
                selected="true"
                change="tree.showExtensions = checkBox.selected;" />
    </mx:ApplicationControlBar>
 
    <mx:FileSystemTree id="tree"
            width="100%"
            height="100%" />
 
</mx:WindowedApplication>

2 Comments

leave a comment
  1. david / Jan 9 2009

    Thanks for these air examples!
    I think you forgot the actionscript code in the second example (it appears to be the same mxml code as in the first example).

  2. Peter deHaan / Jan 9 2009

    david,

    Nope, the ActionScript code is “cleverly” buried within the CheckBox control’s change event handler in the MXML:

    tree.showExtensions = checkBox.selected;

    Peter

Leave a Comment