1
votes

I want to be able to load a local SWFs in an AIR desktop application. The SWF files are located outside of the application itself on the user's hard drive.

The code I'm using is as follows:

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
loader.load(new URLRequest("/Users/Oliver/Documents/sample.swf"));

The file does exist. I can test its existence using the following in Unix:

$ ls /Users/Oliver/Documents/sample.swf

However, the application is throwing the error:

Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.

If I attempt to load the same file from a web location (e.g. http://127.0.0.1/sample.swf), the load succeeds.

I understood that AIR could load both local and remote files. Is this not the case? Ironically, elsewhere in my application I am reading, writing and deleting arbitrary files from the local file system without issue. But I cannot load them?

1

1 Answers

3
votes

I believe the issue is with your path. Try using the File class to get a path to your swf.

var f:File = File.documentsDirectory
f = f.resolvePath("sample.swf");
/* ----- */

loader.load(new URLRequest(f.url));