A FileSystemComboBox defines a combo box control for selecting a location in a file system. The control always displays the selected directory in the combo box's text field. When the combo box's drop-down list is displayed, it shows the hierarchy of directories that contain the selected directory, up to the computer root directory. The user can select a higher-level directory from the list. In this sense, the FileSystemComboBox control's behavior is different from the FileSystemTree, FileSystemList, and FileSystemDataGrid controls that display the directories and files that are contained by the current directory.
For more information on the FileSystemComboBox control, see the Flex 3 Language Reference.
You use the <mx:FileSystemComboBox> tag to define a FileSystemComboBox 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 combo box is automatically populated. By default the directory property is set to the root "Computer" directory, which has no ancestor directories and hence shows no selectable directories in the combo box's drop-down list.
The following example shows four variations on the basic FileSystemComboBox. Each combo box is initially set to the user's desktop directory, in the application's creationComplete handler. The distinct characteristics of the combo boxes are as follows:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="init();">
<mx:Script>
<![CDATA[
import flash.filesystem.File;
private function init():void
{
fcb.directory = File.desktopDirectory;
fcbIndent.directory = File.desktopDirectory;
fcbNoIcons.directory = File.desktopDirectory;
fcbChange.directory = File.desktopDirectory;
}
private function setOutput():void
{
output.text = fcbChange.directory.nativePath;
}
]]>
</mx:Script>
<mx:FileSystemComboBox id="fcb"/>
<mx:FileSystemComboBox id="fcbNoIcons" showIcons="false"/>
<mx:FileSystemComboBox id="fcbIndent" indent="20"/>
<mx:FileSystemComboBox id="fcbChange" directoryChange="setOutput();"/>
<mx:TextArea id="output" width="200" height="50"/>
</mx:WindowedApplication>
The FileSystemComboBox supports the same user interaction as a standard combo box control. The control displays a directory in its selection field. The user clicks the button (or uses the keyboard) to open a drop-down list containing the names of the hierarchy of directories that contain the selected directory. The user can then select one of the directories, which causes the drop-down list to close and the selected directory to become the current directory. When the user selects a directory, the control dispatches the directoryChange event, and its directory property changes to the newly selected directory.