Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

Mobile AIR - FileReference browse() & .zip

Guest
Oct 13, 2011 Oct 13, 2011

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

TOPICS
Development
5.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 24, 2011 Dec 24, 2011

Hi,

If by any chance you got your answer, I'm very interested with it.

Yvan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 24, 2011 Dec 24, 2011

You have to write your own simple file browser with File class (not FileReference)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 27, 2011 Dec 27, 2011

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 29, 2011 Dec 29, 2011

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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 10, 2013 Jan 10, 2013

Thank you for sharing this.  Appreciate it!

Don

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 25, 2013 Oct 25, 2013
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines