| Package | com.myflashlab.air.extensions.fileChooser |
| Class | public class FileChooser |
| Inheritance | FileChooser flash.events.EventDispatcher |
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
See also
| Property | Defined By | ||
|---|---|---|---|
| isOpen : Boolean [read-only] | FileChooser | ||
| Method | Defined 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 | ||
| Constant | Defined By | ||
|---|---|---|---|
| EXTENSION_ID : String = com.myflashlab.air.extensions.fileBrowser [static] | FileChooser | ||
| VERSION : String = 5.0.4 [static] | FileChooser | ||
| isOpen | property |
isOpen:Boolean [read-only] public function get isOpen():Boolean| FileChooser | () | Constructor |
public function FileChooser()initializing the extension
| 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}
|
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():voidto dispose the extension
| EXTENSION_ID | Constant |
public static const EXTENSION_ID:String = com.myflashlab.air.extensions.fileBrowser| VERSION | Constant |
public static const VERSION:String = 5.0.4
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);
}