AIR:的securityError在OSX(而不是在Windows上)与URLStream()是在、而不、securityError、AIR

2023-09-08 14:00:04 作者:少年玩命不玩心,

我使用URLStream加载从硬盘文件(我想继续使用URLStream这样做)。该文件位于应用程序存储:/myfolder/myFile.zip

I'm using URLStream to load a file from the harddisk (and I'd like to continue to use URLStream to do so). The file is located in "app-storage:/myfolder/myFile.zip"

所以我用

var f:File = new File("app-storage:/myfolder/myFile.zip");
myStream.load(new URLRequest(f.nativePath));

在Windows上,这似乎是没有问题的工作 - 但在OS X上使用URLStream调度SecurityErrorEvent.SECURITY_ERROR与消息:

on Windows this seems to work without problems - but on OS X the URLStream dispatches a SecurityErrorEvent.SECURITY_ERROR with the message:

Error #2032: Stream Error. URL: app:/Users/myUserName/Library/Preferences/MyAppName/Local%20Store/myfolder/myFile.zip

有人可以解释我为什么在Windows上运行,但不是在OS X,以及如何解决这个问题呢?

can someone explain me why this works on windows but not on OS X and how to resolve this issue?

推荐答案

好老的,模糊的错误2032!

Good old, ambiguous error 2032!

您可能会想尝试:

var f:File = new File(File.applicationStorageDirectory + "/myFolder/myFile.zip");

修改

我最初的意见是使用 File.applicationStorageDirectory 属性,我仍然认为这是一个好主意。但它看起来像财产归结为您所使用的相同的字符串...所以也许问题是存储目录的位置发生了变化,你要查找的文件仍然在原来的位置?请参阅下面的链接。

My original comment was to use the File.applicationStorageDirectory property, and I still think that's a good idea. But it looks like that property boils down to the same string that you are using ... so perhaps the problem is that the location of the storage dir has changed and the file you are looking for is still in the original location? See link below.

最终修改

请注意的这里关于这条道路取得航空3.3仅适用于Mac OSX的变化发表评论。即使这不解决您的问题,使用此属性应该保护你的code从未来的问题,如果路径发生变化或不同的模式是需要一些其他的设备/ OS。

Note the comment here about a change made to this path in Air 3.3 for Mac OSX only. Even if this doesn't fix your problem, using this property should shield your code from future problems if the path changes or a different "schema" is needed for some other device/OS.