B.9. Chapter 14 Exercise

This exercise asked you to create an application that reads the folder or file properties from the selected row of both the FileSystemDataGrid and FileSystemList components. The solution file is shown in Listing B-16. This file has two functions that operate in the same way. Each will cast the selectedItem from either the FileSystemDataGrid or FileSystemList as a File and then write name and size properties to one of the TextArea components. The results of this can be seen in Figure B-12.

Example B-16. The solution file for the Chapter 14 Exercise
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute" width="650" height="525">
    <!--
    Create a sample application by reading the selected folder or file
    properties from the selected rows of a  FileSystemDataGrid
    and the FileSystemList component.
    -->
    <mx:Script>
        <![CDATA[
        import mx.controls.FileSystemEnumerationMode;
        import flash.filesystem.File;

        public function showFSDGDetails():void {
            var file:File = fsdg.selectedItem as File;
            log1.text += "name: " + file.name  + " size: " + file.size + "\n";
            log1.text += "          nativepath: " + file.nativePath + "\n";
        }
public function showFSLDetails():void {
            var file:File = fsl.selectedItem as File;
            log2.text += "name: " + file.name  + " size: " + file.size + "\n";
            log2.text += "          nativepath: " + file.nativePath + "\n"; } ]]> </mx:Script> <mx:FileSystemDataGrid id="fsdg" horizontalCenter="0" y="10" width="600" height="250" ...

Get Beginning Adobe® AIR™: Building Applications for the Adobe Integrated Runtime now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.