Browsing for multiple files on a user’s computer using Adobe AIR

by Peter deHaan on December 23, 2008 · 1 comment

in File

In a previous example, “Browsing for individual files on a user’s computer using Adobe AIR”, we saw how you could browse for a single file on the user’s computer in Adobe AIR by calling the browseForOpen() method on a File object.

The following example shows how you can browse for multiple files on the user’s computer in Adobe AIR by calling the browseForOpenMultiple() method on a File object.

Full code after the jump.

<?xml version="1.0" encoding="utf-8"?>
<!-- http://airexamples.com/2008/12/23/browsing-for-multiple-files-on-a-users-computer-using-adobe-air/ -->
<mx:WindowedApplication name="File_browseForOpenMultiple_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        width="1000">
 
    <mx:Script>
        <![CDATA[
            private var file:File;
 
            private function btn_click(evt:MouseEvent):void {
                file = new File();
                file.addEventListener(FileListEvent.SELECT_MULTIPLE, file_selectMultiple);
                file.browseForOpenMultiple("Please select a file or three...");
            }
 
            private function file_selectMultiple(evt:FileListEvent):void {
                dataGrid.dataProvider = evt.files;
                dataGrid.visible = true;
            }
        ]]>
    </mx:Script>
 
    <mx:ApplicationControlBar dock="true">
        <mx:Button id="btn"
                label="Click to browse"
                click="btn_click(event);"
                width="100%" />
    </mx:ApplicationControlBar>
 
    <mx:DataGrid id="dataGrid"
            visible="false"
            width="100%"
            height="100%" />
 
</mx:WindowedApplication>

{ 1 comment… read it below or add one }

1 Juan 09.24.09 at 4:53 am

Hi there,

I am just learning how to use Flex/Air. I have created an Air application and I wan to browse in a specific folder located in another computer. In my case I want to explore a folder like: \\127.0.0.5\apache\webapp\logs

My application will run only from inside the network… Any guidance?

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Previous post:

Next post: