0

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.

3
  • i cant see anything wrong with your code - are you getting an error message?
    – user1901867
    Sep 26, 2013 at 22:18
  • 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
    Sep 27, 2013 at 15:02
  • 2
    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
    Sep 27, 2013 at 19:31

1 Answer 1

0

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.

2
  • 1
    This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post.
    – Pranav 웃
    Dec 23, 2013 at 18:39
  • Appreciate your critique. Added some code to explain further. Regards!
    – enguez
    Dec 23, 2013 at 23:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.