0
votes

I'been trying to open a pdf document from inside of an Adobe Air Desktop application created with Adobe Flash CS 6.

I Used this code:

import flash.filesystem.*;

var thePDF = "mypdf.pdf";
var realFile:File = File.applicationDirectory.resolvePath(thePDF);
var destination:File = File.documentsDirectory;
destination = destination.resolvePath(thePDF);
realFile.copyTo(destination,true);
destination.openWithDefaultApplication();

This works fine when I am testing inside Flash CS6, but stops to work when I publish the application in an .exe file (Same case in MACOS with .app file).

I tryied with all the resources I found in google, nothing works!!!

Actualy I found a code from a AS3 library called Shu (com.cjt.Shu) but there is no any documentation recorded in the web.

If any body knows about this Shu or some other alternative even no Open Source. Please let me know.

Thank you all in advance, regards from México.

1
i cant see anything wrong with your code - are you getting an error message?user1901867
No error messages, actualy it works if you try inside flash cs, the problem is when the app is pulish and you exeute, nothing happens.Jose Perez
try adding trace(destination.exists); after the copyTo to see if the pdf actually exists. how is the pdf getting added to the app directory in the first place?user1901867

1 Answers

0
votes

Are you sure that your PDF content is in the folder of the actual published AIR? It looks like the PDF is out of scope.

EDIT: Here´s some code to explain a bit more:

file1.addEventListener(MouseEvent.CLICK, pdf1, false, 0, true);

function pdf1(e:MouseEvent):void{
navigateToURL(new URLRequest(File.applicationDirectory.nativePath + "/files/My_PDF_File.pdf" ));
}

Double check the route of your target file. In my case, it is in the local folder of my published AIR folder in the "files" folder.

Hope this can help you.