Packagecom.myflashlab.air.extensions.fileChooser
Classpublic class FileChooser
InheritanceFileChooser Inheritance flash.events.EventDispatcher

FileChooser is a very easy to work extension to let you choose a file from your sdcard to be able to use it inside your Air project. you can use the choose method and pass the type of file you need by passing its mimetype. */* for example means any file in any extension! but image/* means any image file while image/png means any png image file.

Also remember to add the following activity to your air .xml manifest:

<activity android:name="com.doitflash.fileBrowser.Chooser" android:theme="@style/Theme.Transparent" />

visit www.myflashlabs.com for more extensions.

Make sure to take care of the permissions manually if you are targeting AIR SDK 24+: https://github.com/myflashlab/fileChooser-ANE/#permissions

View the examples

See also

choose()


Public Properties
 PropertyDefined By
  isOpen : Boolean
[read-only]
FileChooser
Public Methods
 MethodDefined By
  
initializing the extension
FileChooser
  
choose($type:String, $title:String, $imageResizeOptions:Object = null):void
use this method to start an activity to let you pic a file type you specify. NOTICE: You must use the resizing object when you are selecting an image file ONLY.
FileChooser
  
dispose():void
to dispose the extension
FileChooser
Public Constants
 ConstantDefined By
  EXTENSION_ID : String = com.myflashlab.air.extensions.fileBrowser
[static]
FileChooser
  VERSION : String = 5.0.4
[static]
FileChooser
Property Detail
isOpenproperty
isOpen:Boolean  [read-only]


Implementation
    public function get isOpen():Boolean
Constructor Detail
FileChooser()Constructor
public function FileChooser()

initializing the extension

Method Detail
choose()method
public function choose($type:String, $title:String, $imageResizeOptions:Object = null):void

use this method to start an activity to let you pic a file type you specify.

NOTICE: You must use the resizing object when you are selecting an image file ONLY. trying this object on other file formats will crash the app of course.

Parameters

$type:String — mimetype for the file you want to select
 
$title:String — title of the file picker dialog shown on some Android versions only
 
$imageResizeOptions:Object (default = null) — image resize object must look like this: {width:500, height:500, quality:50}


Example
This example shows how to select an image and also resize it.
         import com.myflashlab.air.extensions.fileChooser.FileChooser
         import com.myflashlab.air.extensions.fileChooser.FileChooserEvent;
         
         var _ex:FileChooser = new FileChooser();
         _ex.addEventListener(FileChooserEvent.RESULT, onResult);
         _ex.addEventListener(FileChooserEvent.ERROR, onError);
         
         _ex.choose("image/*", "pick an image!", {width:500, height:500, quality:50});
         
         function onResult(e:FileChooserEvent):void
         {
             var originalFile:File = e.param.original;
             
             trace("original file.name = " + originalFile.name);
             trace("original file.extension = " + originalFile.extension);
             trace("original file.size = " + FileSizeConvertor.size(originalFile.size));
             trace("");
             
             // e.param.resized is only available if you are picking an image and have specified the resize object for it.
             var resizedFile:File = e.param.resized;
             if (resizedFile) 
             {
                 trace("resized file.name = " + resizedFile.name);
                 trace("resized file.extension = " + resizedFile.extension);
                 trace("resized file.size = " + FileSizeConvertor.size(resizedFile.size));
                 trace("resized path = " + resizedFile.url);
             }
             
             trace("------------------------------");
         }
         
         function onError(e:FileChooserEvent):void
         {
             trace("onError = " + e.param);
         }
         
dispose()method 
public function dispose():void

to dispose the extension

Constant Detail
EXTENSION_IDConstant
public static const EXTENSION_ID:String = com.myflashlab.air.extensions.fileBrowser

VERSIONConstant 
public static const VERSION:String = 5.0.4

Examples
This example shows how to initialize the extension and how to receive the selected file
     import com.myflashlab.air.extensions.fileChooser.FileChooser
     import com.myflashlab.air.extensions.fileChooser.FileChooserEvent;
     
     var _ex:FileChooser = new FileChooser();
     _ex.addEventListener(FileChooserEvent.RESULT, onResult);
     _ex.addEventListener(FileChooserEvent.ERROR, onError);
     
     _ex.choose("*/*", "pick a file!");
     
     function onResult(e:FileChooserEvent):void
     {
         var file:File = e.param.original as File;
         trace("file.name = " + file.name);
         trace("file.extension = " + file.extension);
         trace("file.size = " + FileSizeConvertor.size(file.size));
         trace("------------------------------");
     }
     
     function onError(e:FileChooserEvent):void
     {
         trace("onError = " + e.param);
     }