Adobe Air is another question for you, but at the beginning there is some experience in the project that I was entrusted with. This is an AIR application that will read assets from a USB key and should work with both WIN and MacOS. The problem is how to load assets into the application on MacOS! It sounds simple enough and works great on Windows.
Here is the code snippet of what I'm 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 OS variable and keyVolume are successfully set in the earlier code. In addition, I have event listener callbacks defined also for ok () and ioErro ().
When this is done, it is displayed on the windows:
Attempt to download: G: \ 0a0ff0ff-f7ae-4b9c-9637-843b1d6c80e8.jpg
Does it exist: true
... and then successfully loads the asset.
On MacOS, it prints:
Attempt to download: /Volumes/AC/0a0ff0ff-f7ae-4b9c-9637-843b1d6c80e8.jpg
Does it exist: true
... and then each time interrupted with an IOError.
Can anyone see what I'm missing here? I have some kind of permission error or something (the file has read / write access). The USB key is formatted in MS-DOS FAT32, can this be a problem?
EDIT
I formatted the new USB key on MacOS to FAT16 and put the files onto it without any problems. The problems remain.
EDIT
Now I'm just trying to load a resource from / users / -USERNAME- / Desktop and still get the same error, so it seems that this is not a rights issue only on a USB drive, it is more common than that.
EDIT
THE PROBLEM IS SOLVED! I finally correctly formulated my Google search and showed 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 also clarified a little the logical operator associated with OS discovery.
I hope someone finds this useful!