A FileSystemList control displays the contents of a file system directory as selectable items in a scrolling list (a Flex List control). The displayed contents can include subdirectories and files, with additional filtering options as well. A FileSystemList control can be linked to a FileSystemHistoryButton control, meaning that the button can be used to move to a previously displayed directory.
For more information on the FileSystemList control, see the Flex 3 Language Reference.
You use the <mx:FileSystemList> tag to define a FileSystemList control in MXML, as the following example shows. Specify an id value if you intend to refer to a component elsewhere in your MXML, either in another tag or in an ActionScript block.
You specify the currently displayed directory using the control's directory property. The directory property can be set in MXML by binding the value to a property or variable, or by setting the property in ActionScript. When you set the directory property, the data provider of the underlying list control is automatically populated. The specified directory isn't displayed in the list--its child files or directories are shown as the items in the list. By default the directory property is set to the root "Computer" directory. In that case its children, which are the drive or drives attached to the computer, are displayed as the items in the list.
The following example demonstrates creating a FileSystemList control that displays all files and folders (the default). The sample also includes a button for navigating up one level in the directory hierarchy. The button is enabled if the currently displayed directory has a parent directory because the button's enabled property is bound to the FileSystemList control's canNavigateUp property. The button navigates up one level by calling the FileSystemList control's navigateUp() method when it is clicked.
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Button label="Up" click="fileList.navigateUp();"
enabled="{fileList.canNavigateUp}"/>
<mx:FileSystemList id="fileList"/>
</mx:WindowedApplication>
The FilesSystemList control provides standard scrolling list functionality for files: a user can scroll through the list of files and select one or multiple files or directories. When the user double-clicks a directory, the FileSystemList control automatically sets that directory as the control's directory property. It then becomes the directory whose contents are displayed in the list.