AIR Included Files Referencing

Hey everyone,

I’ve got a pretty frustrating issue on my hands and am relatively new to publishing AIR applications so its time to see if anyone here has been through the same trials and tribulations.

I am creating an AIR app with all the resources (video/images/xml and most importantly, pdfs) included in the publish. The app works great and everything is very smooth. I am having one silly issue that is driving me berserk.

I’m using HTMLLoader (it’s nice to have since it includes the PDF controls) to pull a PDF into the application when you click on a media link. Here is my exhaustive list of findings:

Before the list, I’ll show the basic structure of the code I am using to load this content in. Note, I am putting “my media url” in the fileURL so in the different findings I can display what I had the fileURL set at for that specific case (yes, it’s almost like I’m programming this forum topic…scary). I’m also removing some extra properties and listeners I’m setting not relevant to the issue at hand. I’m currently testing on Mac OS X, by the way:


var fileURL:String = "my media url";

var htmlLoader:HTMLLoader = new HTMLLoader();

var fileRequest:URLRequest = new URLRequest(fileURL);
htmlLoader.load(fileRequest);

addChild(htmlLoader);

ATTEMPTS:

fileURL = "http://www.myurl.com/myPDF.pdf";

In this attempt, I managed to setup the loader and placed a PDF online to see if it displayed. It worked great, the PDF shows up and I have full control over the content inside. Awesome! (Just to remind, that was not the actual URL to my pdf but I’m just illustrating that I used a direct link to one I put on a server)


_pdfURL = "PDF/myPDF.pdf";
fileURL = File.applicationStorageDirectory.resolvePath(_pdfURL).nativePath;

Here is a tricky one. I found that when I call this, the path returned by this actually ends up showing me that its directly referring to the application storage directory in the Preferences (not as I thought, I was hoping this was referring to the “Included files” I setup earlier. What’s even stranger is that when the appStorageDirectory gets setup it has nothing in it. I would at least think it might bring along with it some or all of my included files or references to them.

  1. Left the code the same and decided to copy my PDF folder straight into the Local Store directory created by the application (Note: The Local Store directory actually gets created when I invoke either the resolvePath or HTMLLoader method). Upon copying the folder inside, all the PDFs were successfully loading in!

END OF ATTEMPTS (how i wish in actuality it was only 3 attempts…)

THE ACTUAL QUESTION (the “cliff notes” of my post)

This leads me to my basic question. How can I get the “url” of the Included Files for the AIR app? Is it possible? And if not, what other method would you recommend to display the PDF? Remember, I’m not entirely sold on having it show up in the application, it would be great to open the file directly and have it open with Adobe Reader or Acrobat. I couldn’t figure that out initially so that’s why I’m stuck here.

If you’ve made it this far in the post, I thank you sincerely. I know its tough going through these longer ones…Hope someone can help!

Thanks.