在Mac和寡妇Adobe AIR文件路径 [英] Adobe AIR file path on MAC and widows
问题描述
我有一个Adobe AIR应用程序(基于闪存),在从目录PNG文件加载,有一个文本文件,指定路径,但它似乎并不奏效的OSX,而只是正常的的Windows
Windows路径
C:\用户\用户\文档\树
这工作得很好,但是MAC路径
文件:///用户/用户/桌面/株/
或
用户/用户/桌面/株/
不工作,试图扭转削减,也没有帮助,任何人都可以帮忙吗?
更新,继承人的laods在树上的功能
私有函数LoadTrees():无效
{
尝试
{
树=新的Array();
VAR currentDirectory所:文件=新的文件(currentPath);
var中的文件:阵列= currentDirectory.getDirectoryListing();
对于(VAR我:= 0; I< files.length;我++)
{
VAR fullFilePath:字符串= treePathLoader.data +\\+文件[我]。名称;
VAR树:树;
如果(fullFilePath.indexOf(PNG)大于0)
{
树=新树(fullFilePath,treePositions.Tree [I] .X,treePositions.Tree [I] .Y,treePositions.Tree [I] .scale);
Trees.push(树);
}
}
}
赶上(五:错误)
{
跟踪(ERROR);
}
}
如果您不能确定,您可以使用文件分割符斜杠。 这个例子正常工作对我来说:
文件://+ File.desktopDirectory.nativePath.toString()+文件分割符+'树'+文件分割符
I have an Adobe Air application(based in flash) that loads in PNG files from a directory, there is a text file to specify the path, however it doesn't seem to be working on OSX while it works just fine on Windows
Windows path
C:\Users\User\Documents\Trees
This works just fine, however mac path
file:///Users/user/Desktop/trees/
or
Users/user/Desktop/trees/
Doesnt work, tried to reverse the slashed, didn't help either, anyone could help?
Update, heres the function that laods in the trees
private function LoadTrees():void
{
try
{
Trees = new Array();
var currentDirectory:File = new File(currentPath);
var files:Array = currentDirectory.getDirectoryListing();
for (var i:int = 0; i < files.length; i++)
{
var fullFilePath:String = treePathLoader.data + "\\" + files[i].name;
var tree:Tree;
if (fullFilePath.indexOf(".png") > 0)
{
tree = new Tree(fullFilePath, treePositions.Tree[i].x, treePositions.Tree[i].y,treePositions.Tree[i].scale);
Trees.push(tree);
}
}
}
catch(e:Error)
{
trace("ERROR");
}
}
If you are not sure about the slash you can use File.separator. this example works fine for me:
"file://" + File.desktopDirectory.nativePath.toString() + File.separator + 'trees' + File.separator
这篇关于在Mac和寡妇Adobe AIR文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!