as3 Air 浏览 sd 卡上的文件?

编程入门 行业动态 更新时间:2024-10-28 14:25:10
本文介绍了as3 Air 浏览 sd 卡上的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

希望能够使用 as3 air 从用户手机中浏览和选择文件.

Looking to be able to have access to browse and select a file from the users phone using as3 air.

此代码仅弹出一个上传框并显示未找到文件".但我知道我的手机上有一个 zip,所以它一定没有选择正确的文件夹路径.如何更改它以使其访问整个手机?

This code only pops up an upload box and says "No Files were found". But I know I have a zip on my phone so it must not be choosing the right folder path. How can I change that to make it access the entire phone?

function unzip_init():void{ fileFilter = new FileFilter("selected your zip file.", "*.zip; *.gz2; *.bz2;"); file = new File(); //file.browseForDirectory("Choose a directory"); // Only got me the directory path file.browseForOpen("Open", [fileFilter]); file.addEventListener(Event.SELECT, onSelectedFile); }

推荐答案

从SD卡中获取所有mp3文件

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(); } } } }

更多推荐

as3 Air 浏览 sd 卡上的文件?

本文发布于:2023-11-23 15:14:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621902.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:卡上   文件   Air   sd

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!