【问题标题】:Adobe AIR file path on MAC and widowsMAC 和 windows 上的 Adob​​e AIR 文件路径
【发布时间】:2011-10-03 22:04:20
【问题描述】:

我有一个 Adob​​e Air 应用程序(基于 Flash),它从一个目录加载 PNG 文件,有一个文本文件来指定路径,但是它似乎不能在 OSX 上工作,而它在 OSX 上工作得很好窗户

窗口路径

C:\Users\User\Documents\Trees

这很好用,但是 mac 路径

file:///Users/user/Desktop/trees/

Users/user/Desktop/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");
            }
        }

【问题讨论】:

  • 不确定这个 treePathLoader.data 是什么...它向您展示了什么?

标签: actionscript-3 adobe air


【解决方案1】:

如果您不确定斜线,您可以使用 File.separator。 这个例子对我来说很好:

"file://" + File.desktopDirectory.nativePath.toString() + File.separator + 'trees' + File.separator

【讨论】:

  • 我已经添加了一个代码示例,如何将其合并到函数中?谢谢!
【解决方案2】:

你试过/Users/user/Desktop/trees/吗?或者可能是~/Desktop/trees/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-17
    相关资源
    最近更新 更多