希望为Android应用程序创建一个AS3 air,它可以循环访问文件夹和 从文件夹中的所有mp3中随机选择并播放其中一个。后 它完成播放它将转到下一个文件夹并执行相同的操作直到它有 完成了50个随机引用。
我真正需要帮助的是......
Using AS3 how do I select the contents of local folder or sub
folder and put them into an array and randomly choose one
from that array?
如果我知道怎么做,那么我可以将它用于音频文件,然后应用它 调用50个随机图像的结构相同。
注意循环必须按此顺序排列,原因我不在此解释。
我添加了一张图片,以便您可以看到我想要做的事情。
答案 0 :(得分:2)
此代码获取文件夹的内容。
import flash.filesystem.File;
var desktop:File = File.applicationDirectory.resolvePath("TheFilePathYouChoose/Choice");
var files:Array = desktop.getDirectoryListing();
for (var i:uint = 0; i < files.length; i++)
{
trace(files[i].nativePath); // gets the path of the files
trace(files[i].name);// gets the name
}
答案 1 :(得分:0)
AS3中的每个Folder
对象都有一个documents属性,类型为ArrayCollection
,您可以从中访问.length
,然后随机选择一个文件从索引0到.length - 1
。然后将文件的路径推送到播放列表阵列。每个File
对象都有一个.nativePath
属性,这是您应该用于路径的属性。然后只是指示你的播放器按照你想要的顺序播放路径。
你 使用AIR,对吗?这在普通Flash中不起作用。