<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" 
                        creationComplete="onCreationComplete()" viewSourceURL="srcview/index.html">
                        
    <mx:Script>
        <![CDATA[
            
            [Bindable]protected var dir:File;
            
            protected function onCreationComplete():void {
                StorageVolumeInfo.storageVolumeInfo.addEventListener(StorageVolumeChangeEvent.STORAGE_VOLUME_MOUNT, onVolumeMount);
                StorageVolumeInfo.storageVolumeInfo.addEventListener(StorageVolumeChangeEvent.STORAGE_VOLUME_UNMOUNT, onVolumeUnmount);
            }
            
            protected function onVolumeMount(e:StorageVolumeChangeEvent):void {
                dir = e.rootDirectory;
            }
            
            protected function onVolumeUnmount(e:StorageVolumeChangeEvent):void {
                
            }
            
            protected function onFileChosen():void {
                var file:File = tree.selectedItem as File;
                file.openWithDefaultApplication();
            }
        ]]>
    </mx:Script>
    
    <mx:FileSystemTree id="tree" width="100%" height="100%" labelField="@label"
                showRoot="false" directory="{dir}" fileChoose="{onFileChosen()}"/>
    
</mx:WindowedApplication>