Copy link to clipboard
Copied
I am trying to load a zip file which is in /mnt/sdcard/download/ on my Android phone. Using the following code:
m_fileReference = new flash.net.FileReference();
m_fileReference.browse();
But when I open the app and browse I am only able to see video, audio and image files. Does anybody know how I can load a zip file?
Thanks
--Matt
Copy link to clipboard
Copied
Hi,
If by any chance you got your answer, I'm very interested with it.
Yvan
Copy link to clipboard
Copied
You have to write your own simple file browser with File class (not FileReference)
Copy link to clipboard
Copied
I tried to use the File.browseForOpen with and without extension filters but I am getting either a No file found message or the choice with audio/video/picture files only. Am I missing something?
Copy link to clipboard
Copied
It is not so easy... You have to actualy make your own view for viewing and selecting files on the sd card. You can do this easily by passing objects between views. Try this for a start (works on my android phone):
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
title="Browse"
creationComplete="init();">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable] private var currentDirectory:File;
[Bindable] private var files:ArrayCollection;
private var returnObject:Vector.<File>;
override public function createReturnObject():Object{
return returnObject;
}
private function init():void{
changeDir( File.desktopDirectory );
}
private function changeDir(file:File):void{
if(file.isDirectory){
var parent:File = file.parent;
currentDirectory = file;
files = new ArrayCollection( currentDirectory.getDirectoryListing().sort(fileSort) );
}
}
private function fileSort(file1:File, file2:File):int{
if(file1.isDirectory && !file2.isDirectory)
return -1;
else if(!file1.isDirectory && file2.isDirectory)
return 1;
else
return file1.name.localeCompare( file2.name );
}
private function doubleClick():void{
if(fileList.selectedItem == null)
return;
var selectedFile:File = fileList.selectedItem;
if(selectedFile.isDirectory)
changeDir(selectedFile);
else{
returnObject = new <File>[ selectedFile ];
navigator.popView();
}
}
private function up():void{
changeDir( currentDirectory.parent );
}
]]>
</fx:Script>
<s:VGroup width="100%"
height="100%">
<s:Button label="Up"
click="up();"
width="100%"
enabled="{currentDirectory.parent != null}"/>
<s:List id="fileList"
width="100%"
height="100%"
dataProvider="{files}"
doubleClick="doubleClick();"
doubleClickEnabled="true"
labelField="name">
</s:List>
</s:VGroup>
</s:View>
Copy link to clipboard
Copied
Thank you for sharing this. Appreciate it!
Don
Copy link to clipboard
Copied
Hi er453r,
I would like to reference your sample code for browsing and selecting different file type in Android. However, I do not know what are the properties for "fileList" and "navigator" from the above sample.
For your information, I am using AS3 with FlashIDE
Can you tell me what it is? Thank in advance.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more