Link to PDF in Actionscript 3


#1

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


#2

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” );


#3

navigateToURL(link, “_blank”);

maybe?


#4
button.addEventListener(MouseEvent.CLICK, launchPDF);

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

#5

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:


#6

Hi all,

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


#7

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


#8

then you need some php :wink:


#9

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


#10

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


#11
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: http://www.computing.net/answers/webdevel/error-php-file-to-download-pdf/3828.html :slight_smile:


#12

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.