gpt4 book ai didi

actionscript-3 - Adobe AIR 和不同的操作系统文件系统

转载 作者:行者123 更新时间:2023-12-04 16:01:55 25 4
gpt4 key购买 nike

另一个针对您的 Adob​​e Air 问题,但首先这里是我负责的项目的一些背景知识。它是一个 AIR 应用程序,可以从 USB key 读取 Assets ,并且必须在 WIN 和 MacOS 上运行。问题是,如何在 MacOS 上将 Assets 加载到应用程序中!听起来很简单,并且可以在 Windows 上无缝运行。

这是我正在尝试做的代码片段:

            var loader:Loader = new Loader(); 
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, ok);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);

var p:String;

if (os == "mac")
{
p = "/Volumes/" + keyVolume.rootDirectory.name + File.separator + "0a0ff0ff-f7ae-4b9c-9637-843b1d6c80e8.jpg";
}
else
{
p = keyVolume.rootDirectory.name + File.separator + "0a0ff0ff-f7ae-4b9c-9637-843b1d6c80e8.jpg";
}

var temp:File = new File(p);
Debugger.Display.text += "\nAttempting to load: " + p;
Debugger.Display.text += "\nDoes it exist? " + temp.exists;
loader.load(new URLRequest(p));

...变量 OS 和 keyVolume 已在早期代码中成功设置。此外,我还为 ok() 和 ioErro() 定义了事件监听器回调。

当它运行时,它会在 Windows 上打印出来:

正在尝试加载:G:\0a0ff0ff-f7ae-4b9c-9637-843b1d6c80e8.jpg
是否存在:true

...然后成功加载 Assets 。

在 MacOS 上,它打印出:

正在尝试加载:/Volumes/AC/0a0ff0ff-f7ae-4b9c-9637-843b1d6c80e8.jpg
是否存在:true

...然后每次都以 IOError 失败。

任何人都可以看到我在这里缺少的东西吗?我是否有某种权限错误或什么(文件具有“读/写”访问权限)。 USB key 被格式化为 MS-DOS FAT32,这会不会有问题?

编辑

我在 MacOS 中将新的 USB key 格式化为 FAT16 并将文件放入其中,但没有成功。问题依然存在。

编辑

我现在只是尝试从/users/-USERNAME-/Desktop 加载 Assets ,但仍然收到相同的错误,所以看起来这不仅仅是 U 盘上的权限问题,它比这更普遍。

编辑

问题解决了!我终于正确地表达了我的 Google 搜索结果 revealed the answer .

这些更改将解决问题:
            var loader:Loader = new Loader(); 
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, ok);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);

var p:String = keyVolume.rootDirectory.nativePath + ((os == "mac") ? File.separator : "") + "0a0ff0ff-f7ae-4b9c-9637-843b1d6c80e8.jpg";
var temp:File = new File(p);
Debugger.Display.text += "\nAttempting to load: " + temp.url;
Debugger.Display.text += "\nDoes it exist? " + temp.exists;
loader.load(new URLRequest(temp.url));

我还稍微改进了涉及操作系统检测的逻辑语句。

我希望有人觉得这很有用!

最佳答案

问题解决了!我终于正确地表达了我的 Google 搜索结果 revealed the answer .

这些更改将解决问题:

            var loader:Loader = new Loader(); 
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, ok);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);

var p:String = keyVolume.rootDirectory.nativePath + ((os == "mac") ? File.separator : "") + "0a0ff0ff-f7ae-4b9c-9637-843b1d6c80e8.jpg";
var temp:File = new File(p);
Debugger.Display.text += "\nAttempting to load: " + temp.url;
Debugger.Display.text += "\nDoes it exist? " + temp.exists;
loader.load(new URLRequest(temp.url));

我还稍微改进了涉及操作系统检测的逻辑语句。

我希望有人觉得这很有用!

关于actionscript-3 - Adobe AIR 和不同的操作系统文件系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4904518/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com