Reputation: 2869
Another Adobe Air question for you but first here some background into the project I have been tasked with. It is an AIR app that will read assets from a USB key and must work on both WIN and MacOS. The problem is, how do I load assets into the app on MacOS! Sounds simple enough and works seamlessly on Windows.
Here is a code snippet of what i am trying to do:
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));
... the variable OS and keyVolume are being successfully set in earlier code. Also, I have the event listener callbacks defined as well for ok() and ioErro().
When this is run it prints out on windows:
Attempting to load: G:\0a0ff0ff-f7ae-4b9c-9637-843b1d6c80e8.jpg
Does it exist: true
... and then successfully loads the asset.
On MacOS, it prints out:
Attempting to load: /Volumes/AC/0a0ff0ff-f7ae-4b9c-9637-843b1d6c80e8.jpg
Does it exist: true
... and then fails with an IOError every time.
Can anyone see something that I am missing here? Do I have some sort of permission error or something (file has "read / write" access). The USB key is formatted in MS-DOS FAT32, could that be a problem?
EDIT
I formatted a new USB key in MacOS to FAT16 and put the files onto it with no success. Problems remain.
EDIT
I am now just trying to load an asset from /users/-USERNAME-/Desktop and still am receiving the same error, so it looks like it isn't a permissions issue on just the USB stick, it is more widespread than that.
EDIT
PROBLEM SOLVED! I finally worded my Google search correctly and it revealed the answer.
These changes will fix the problem:
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));
I have also refined the logical statement involving the OS detection a bit as well.
I hope someone finds this useful!
Upvotes: 6
Views: 682
Reputation: 2869
PROBLEM SOLVED! I finally worded my Google search correctly and it revealed the answer.
These changes will fix the problem:
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));
I have also refined the logical statement involving the OS detection a bit as well.
I hope someone finds this useful!
Upvotes: 1