Link to PDF in Actionscript 3

Hi,

can anyone help me with how to link to a pdf in Actionscript 3

Using this code at the moment, and it does not seem to work:

var link:URLRequest = new URLRequest(“myPdf.pdf”);
button_mc.addEventListener(MouseEvent.CLICK, OnClick );
function OnClick(event:MouseEvent):void
{
navigateToURL(link);
}

help will be very much appreciated

when you say link to a pdf what exactly do you want to do with it

if you want to open up the page in the broswer you just need to use the getURL function

getURL( “http://www.adobe.com/software/flash/flashpro/” , “_blank” );

navigateToURL(link, “_blank”);

maybe?

button.addEventListener(MouseEvent.CLICK, launchPDF);

function launchPDF(e:MouseEvent):void
{
    navigateToURL(new URLRequest("yourpdf.pdf"));
}

in AS3 you use navigateToURL, not getURL, and you give it a URLRequest that is created using a string, not just the string.

rondog has it perfect :wink: and if you want it to open in a new window add a second argument to the navigateToURL function that is “_blank”

The reason your first one was not working was because you had an extra semi-colon in there. Semi colons go after a line of code, not after the string inside the function call :slight_smile:

Hi all,

thanks a lot for all the suggestions. You are great. I will try them out tonight :slight_smile:

that is for viewing but lets say I wanted someone to be able to download a pdf so they can keep it.

like say a cv…

what would that involve.

thanks

then you need some php :wink:

do you know where I could find a tutorial or some more info on that?
any pointers would be appreciated.
thanks

you could just zip up the pdf into a archive file and then put it on your server and make a direct link to it. It will automatically start downloading to the desktop once someone clicks a link to a zip file good luck

do you know where I could find a tutorial or some more info on that? any pointers would be appreciated. thanks

Think this will help: Is There Any Way To Fix The Error From A PDF File? - Computing.net: Question & Answers Forum :slight_smile:

thanks for your replies.
the zip file may be the easiest for my needs but I
will start playing around with some simple php stuff too.
Ill add it to my to do list.