Using the Flex Apollo components
Back to: Apollo Documentation home page
You use the Flex Apollo components in an Apollo application to display HTML web pages, and file information for the system on which the Apollo application executes. You can display files system information in a list, tree, or data grid format. For example, you can use the FileSystemDataGrid control to display file information in a data grid format that includes the file name, creation date, modification date, type, and size.
| Contents |
|---|
About the Flex Apollo components
Flex provides the following Apollo components:
- ApolloApplication container - defines the application container that you use to create Flex applications for Apollo. The ApolloApplication container adds window-related functionality to the Flex Application container when you build Apollo applications.
- HTML control - displays HTML web pages in your application.
- FileSystemComboBox control - defines a combo box control for selecting a location in a file system.
- FileSystemDataGrid control - displays file information in a data grid format. The file information displayed can include the file name, creation date, modification date, type and size.
- FileSystemHistoryButton control - use with a FileSystemList or FileSystemDataGrid control to let the user move backwards or forwards through the navigation history of the control.
- FileSystemList control - displays the contents of a file system directory.
- FileSystemTree control - displays the contents of a file system directory as a tree.
For more information on these components, see the Apollo ActionScript 3.0 Language Reference.
Flex Apollo example
The following example uses the ApolloApplication container and the FileSystemTree and FileSystemDataGrid controls. In this example, the FileSystemTree control displays a directory structure. Clicking a directory name in the FileSystemTree control causes the FileSystemDataGrid control to display information about the files in the selected directory:
<?xml version="1.0" encoding="utf-8"?>
<mx:ApolloApplication xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:HDividedBox>
<mx:FileSystemTree id="tree"
width="200" height="100%"
directory="{new File('C:\\')}"
enumerationMode="directoriesOnly"
change="dataGrid.directory = File(tree.selectedItem);"/>
<mx:FileSystemDataGrid id="dataGrid"
width="100%" height="100%"
directory="{new File('C:\\')}"/>
</mx:HDividedBox>
</mx:ApolloApplication>
Using the Flex Apollo sample components
Along with the Flex Apollo components described above, Flex includes three sample MXML components created using the Flex Apollo components. These three sample components are included in the Flex Builder 2\Apollo SDK\samples directory, and include the following components:
- DirectorySelectionPanel.mxml - Opens a window that lets you select a directory. When you select a directory, the component dispatches a
selectevent, of type FileEvent. Thefileproperty of the event object, of type File, contains the selected directory.
- FileOpenPanel.mxml - Opens a window that lets you select a file. When you select a file, the component dispatches a
selectevent, of type FileEvent. Thefileproperty of the event object, of type File, contains the selected file.
- FileSavePanel.mxml - Opens a window that lets you save a file. You pass to the component's
show()method the directory and name of the file to save. When you select a destination file for the save, the component dispatches aselectevent, of type FileEvent. Thefileproperty of the event object, of type File, contains the destination file.
The sample components all work as popup windows, much like the Flex Alert control. To open a component in your application, you use the component's static show() method, as the following example shows for FileOpenPanel.mxml. This example displays the name of the selected file in a TextArea control.
This example assumes that you have copied FileOpenPanel.mxml to the directory containing the application file:
<?xml version="1.0" encoding="utf-8"?>
<mx:ApolloApplication xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.events.FileEvent;
import mx.containers.Panel;
// Open the FileOpenPanel component.
private function openButton_clickHandler(event:MouseEvent):void
{
var panel:Panel = FileOpenPanel.show();
panel.addEventListener(FileEvent.SELECT, fileOpenPanel_selectHandler);
}
// Write the selected file name to the TextArea control.
private function fileOpenPanel_selectHandler(event:FileEvent):void
{
myTA.text=event.file.nativePath;
}
]]>
</mx:Script>
<mx:Button label="Select File"
click="openButton_clickHandler(event);"/>
<mx:TextArea id="myTA"/>
</mx:ApolloApplication>
About Flex Builder and the Flex Apollo components
Flex Builder requires the apolloframework.swc and apolloglobal.swc files to compile an application that uses the Flex Apollo components.
To use the Flex Apollo Components in Flex Builder, you must install the Apollo Extensions for Flex Builder. After installing the extensions, you can create an Apollo project. For more information about installing the Apollo Extensions for Flex Builder and creating an Apollo project, see Set up instructions for Flex Builder users and Using the Apollo Extensions for Flex Builder.
The major difference between the Flex Builder configuration for a standard Flex application and for a Flex Apollo application are the SWC files referenced by the Flex Apollo application. When you create a Flex Apollo application, Flex Builder automatically performs the following steps:
- Removes Flex Builder 2\Flex SDK 2\frameworks\libs\playerglobal.swc from the Library Path of your application.
- Adds Flex Builder 2\Apollo SDK\frameworks\libs\apollo\apolloframework.swc and Flex Builder 2\Apollo SDK\frameworks\libs\apollo\apolloglobal.swc to the Library Path of your application.
Using the ApolloApplication component
The mx:ApolloApplication container component defines an Apollo application object that includes its own window controls. In an MXML Apollo application created by using the Flex Extensions for Apollo, an <ApolloApplication> tag replaces the <Application> tag. The ApolloApplication container replaces the ApplicationWindow control.
An ApolloApplication component provides the following controls:
- A title bar
- A minimize button
- A maximize button
- A close button
The window that the ApolloApplication component defines conforms to the standard behavior of the operating system. The user can move the window by dragging the title bar and resize the window by dragging on any side or corner of the window.
By default, the ApolloApplication component creates an application window for which windowMode is set to systemChrome, and visibility is set to true. These settings are made in the application.xml file that Flex Builder generates for an Apollo application. To eliminate the system chrome and window controls that the ApolloApplication component creates by default, edit the opening and closing ApolloApplication tags in the MXML file so that they are Application tags and, in the application.xml file, set the systemChrome to none.
The following simple application shows how the ApolloApplication component works:
<?xml version="1.0" encoding="utf-8"?>
<mx:ApolloApplication
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
<mx:Text text="Hello World" />
</mx:ApolloApplication>
For more information about the ApolloApplication container and other Flex Apollo components, see the Apollo ActionScript 3.0 Language Reference.
Back to: Apollo Documentation home page