开发者

Adobe AIR file path on MAC and widows

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
            {开发者_JAVA百科
                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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜