Skip to main content
Known Participant
April 17, 2012
Question

opening a pdf file in a relative link / local

  • April 17, 2012
  • 1 reply
  • 6131 views

Maybe this sounds simple.

But I get used to AS2 code to open  a pdf file like the code below:

getURL("pdfDocuments/pdfname.pdf","_blank")

As I search uncle Google I'm stuck to this as equivalent to getURL in AS2.

btn.addEventListener(MouseEvent.CLICK, btnClick);

function btnClick(e:MouseEvent):void {

          navigateToURL( new URLRequest("pdfDocuments/pdfname.pdf"), "_blank");

}

But still it did'nt work.

Before in AS2 getURL working on mailto, pdf on a relative link and a typical url's.

But as to AS3 navigateToURL function only works on mailto and typical url.

Any tweaks to the code above, to get it to work? will much appreciated.

Thanks,

This topic has been closed for replies.

1 reply

Inspiring
April 17, 2012

var myLoader:Loader = new Loader();                                                   // create a new instance of the Loader class

var url:URLRequest = new URLRequest("pdfDocuments/pdfname.pdf"); // in this case both SWFs are in the same folder

myLoader.load(url);                                                                             // load the pdf file

addChild(myLoader); 

sinious
Legend
April 17, 2012

I thought it worked the same myself until someone posted about it and I tested it. I tested all combinations of relative, full URLs, file:///, etc etc. It appears you simply cannot launch like that anymore.

If your SWF is in a HTML page then you can always let JavaScript do the work. Send an ExternalInterface call to JavaScript passing the relative path of the PDF and have it window.open() to it.

Known Participant
April 18, 2012

any example sir or site that do the same?

Thanks for the reply, much appreciated.