Looking to be able to have access to browse and select a file from the users phone using as3 air.
This code only pops up an upload box and says \"No Files were foun
To get all the mp3 files from the SD card
var ROOT:File = File.documentsDirectory.resolvePath("/sdcard/");
var FILES:Array = ROOT.getDirectoryListing();
var TrackN:int;
var SUBFOLDER:String;
for (var i:int = 0; i < FILES.length; i++)
{
var File_Ext:String;
File_Ext = "" + FILES[i].extension;
if (File_Ext.toLowerCase() == "mp3")
{
TrackN++;
list.addItem( { label:FILES[i].name, data:TrackN, Song:FILES[i].url} );
}
if (FILES[i].isDirectory == true)
{
SUBFOLDER = "" + FILES[i].nativePath;
getSubfolders();
}
function getSubfolders()
{
var SUBF:File = File.documentsDirectory.resolvePath(SUBFOLDER);
var FLIST:Array = SUBF.getDirectoryListing();
for (var s:int = 0; s < FLIST.length; s++)
{
File_Ext = "" + FLIST[s].extension;
if (File_Ext.toLowerCase() == "mp3")
{
TrackN++;
list.addItem( { label:FLIST[s].name, data:TrackN, Song:FLIST[s].url} );
}
if (FLIST[s].isDirectory == true)
{
SUBFOLDER = "" + FLIST[s].nativePath;
getSubfolders();
}
}
}
}
I gave you an answer here: as3 get zip file on phone from app - file path then unzip
Basically you have to write your own file browser, help documentation suggests this (however they could built it in). e.g.
var rootDirs:Array = File.getRootFirectories();//all available root dirs
then you can pick one and lists it's content
if(rootDirs && rootDirs.length > 0)
{
var dir:File = rootDirs[0]
if(dir.isDirectory)
{
//try to enumerate it's content
var files:Array = dir.getDirectoryListing();
}
}
best regards