Adobe AIR file path on MAC and widows

谁说胖子不能爱 提交于 2019-12-12 02:46:32

问题


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

回答1:


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



回答2:


Did you try with /Users/user/Desktop/trees/? Or possibly ~/Desktop/trees/.



来源:https://stackoverflow.com/questions/7641203/adobe-air-file-path-on-mac-and-widows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!