Check out File.applicationDirectory to access content located in your AIR application directory.
Something like this usually does the trick:
var mySWF:File = File.applicationDirectory.resolvePath("swfs/my.swf")
Hope that helps.
Thanks for the response. Why doesn't the Loader class work? Just curious. It be good from the standpoint of being able to develop one set of code that works on the web and in AIR. Also, the AS3 documentation says the Loader class its supported by AIR runtime.
It does, it's a matter of figuring out where the realative path points to with AIR -- which I believe becomes c:/program files/[yourapp]/swfs/my.swf
which is also known as File.applicationDirectory.resolvePath("swfs/my.swf") per Chris...
Tyr installing your app, then placing the folder of swfs in the app folder (like c:/program files/[yourapp]/swfs/my.swf)
Oh. Sorry. Your response reminded me of an import detail. The paths fail to link ONLY in Test Movie. When I build and run the application, they link fine. In test movie, they give me a url not found error.
ah, I think the path for the swfs is local to the .fla then...
Moved to the Adobe AIR Development forum
Okay. So I don't know if this is what people have been saying, but I found a solution. I previously had
then from shell running in the Flash player with test movie I could use "../swfs/game.swf" to load the game swf.
When running in AIR and test movie in Flash, I have to move the swfs folder to the shell folder like this
The AIR test movie will then successfully link to the game.swf. Maybe its ignoring the ".." of my original path?
I believe we tend to encourage AIR developers to not make use of hand-coded relative paths - and to instead rely on these routines
Also, and I apologize I can't seem to find it in the docs right now, but I believe AIR also imposes rules on File.resolvePath("..") and File.parent that disallow traversing up the file directory hierarchy above the root of the installed application.
You can of course work around this by manually constructing a File like this:
var rootDir:File = File.applicationDirectory;
trace(rootDir.nativePath); // C:\Documents and Settings\cthilgen\Desktop\p-test-as-clean\bin-debug
var rootDirParentBad:File = rootDir.parent;
trace(rootDirParentBad); // rootDir.parent is null - can't rise above app root folder
var rootDirParentGood:File = new File( rootDir.nativePath + "/.." );
trace(rootDirParentGood.nativePath); // C:\Documents and Settings\cthilgen\Desktop\p-test-as-clean
Hope this helps.