且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Mac和寡妇Adobe AIR文件路径

更新时间:2023-12-03 19:12:52

如果您不能确定,您可以使用文件分割符斜杠。 这个例子正常工作对我来说:

 文件://+ 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