A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Open a pdf in a new window?

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    21

    Open a pdf in a new window?

    I am new to flash and would like to create a button that opens a pdf in a new window. How would you do that?

  2. #2
    Member
    Join Date
    Apr 2009
    Posts
    58
    What version of flash do you have, and what version of ActionScript?

  3. #3
    Member
    Join Date
    Apr 2009
    Posts
    58
    If you're using ActionScript 2.0, try this, replacing "http://www.flashkit.com" with the web address of your pdf. You can replace "_new" with "_blank" to allow the browser to open the pdf in a new tab. Any browser that does not use tabs would open it in a new window no matter which of the two you choose.

    on(release){
    getURL("http://www.flashkit.com","_new");
    }

  4. #4
    Junior Member
    Join Date
    Apr 2010
    Posts
    21
    Thanks guys that was perfect. Does the code change though once you start using AS 3?

  5. #5
    Member
    Join Date
    Apr 2009
    Posts
    58
    This AS3 code would do what the previous code did when you used "_blank". I don't know how to force a new window when the browser has tabs, though.

    function gotoPDF(e:MouseEvent):void {
    var myPDFURL:URLRequest = new URLRequest("http://www.addictinggames.com/");
    navigateToURL(myPDFURL);
    }

    myButton.addEventListener(MouseEvent.CLICK, gotoPDF);

  6. #6
    Member
    Join Date
    Apr 2009
    Posts
    58
    Also, if you want to put the code on the main timeline in as2, you could use this:

    myButton.onRelease = function() {
    getURL("http://www.flashkit.com","_new");
    }

  7. #7
    Banned
    Join Date
    Mar 2014
    Posts
    1
    It fills that use, but isn't pdf kind of a critical thing? Chrome opens pdf so I've managed to use windows 8 for a week without realizing that 8 has a built in pdf reader and that it is an app (all of the pdfs i've viewed have been hosted online in such a manner that I could view them without downloading). PDF is still incredibly common and I just can't wrap my head around why microsoft saw need to provide .iso support natively but not true pdf support.

  8. #8
    Junior Member
    Join Date
    Jun 2013
    Posts
    25
    Quote Originally Posted by juliervacca View Post
    It fills that use, but isn't pdf kind of a critical thing? Chrome opens pdf so I've managed to use windows 8 for a week without realizing that 8 has a built in pdf reader and that it is an app (all of the pdfs i've viewed have been hosted online in such a manner that I could view them without downloading). PDF is still incredibly common and I just can't wrap my head around why microsoft saw need to provide .iso support natively but not true pdf support.
    Yup indeed, I agree with juliervacca. But if the PDF reader can be web-based, we can open PDF files online directly. It will be much more convenient.



    Best regards,
    Arron

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center