A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: Action script 3.0 opening a pdf.swf file in its own window

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    11

    Action script 3.0 opening a pdf.swf file in its own window

    hi im having no luck with this at all. im building a site for my company, building and selling homes. ive made a website in flash, nothing too complex, ive also made a pdf in indesing, which when published left me put a page turing feature on it, and that pdf was then published as a swf file. its put all the code in for me automatically so the people can now interact and page turn it.


    i simply want a button/link i can put on my site to open this swf in its own browser window or in a flash player window. this code in previous versions of flash has been easy...on release etc but now with as 3.0 i see people using child, navigatetourl, its so confusing and every example ive found just doesnt seem to work.

    can anyone suggest some simple code to put on a button that when clicked will open my swf file either in a broswer window/pop up window/flash player window i dont care as long as it opens it.



    thanks very much for reading this post and any help is much appreciated.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    myButton.addEventListener(MouseEvent.CLICK, cHandler);
    function cHandler(event:MouseEvent):void
    {
    navigateToURL(new URLRequest("mypage,html"));
    }
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    Dec 2010
    Posts
    11

    thank you

    thanks for the reply this has driven me nuts, when i get time later ill try this straight away, thank you for the reply.

  4. #4
    Junior Member
    Join Date
    Dec 2010
    Posts
    11
    i dont understand this. my fla file is in the same folder as my html page, which ive redone and saved as mypage.html. ive made a button called it instance myButton saved file tested and all it does is open a new firefox window..and google as my home page, its not opening my html file....just a standard firefox window...

  5. #5
    Junior Member
    Join Date
    Dec 2010
    Posts
    11
    if i use this code

    myButton.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF);

    var fl_Loader:Loader;

    //This variable keeps track of whether you want to load or unload the SWF
    var fl_ToLoad:Boolean = true;

    function fl_ClickToLoadUnloadSWF(event:MouseEvent):void
    {
    if(fl_ToLoad)
    {
    fl_Loader = new Loader();
    fl_Loader.load(new URLRequest("page1.swf", 1));
    addChild(fl_Loader);
    }
    else
    {
    fl_Loader.unload();
    removeChild(fl_Loader);
    fl_Loader = null;
    }
    // Toggle whether you want to load or unload the SWF
    fl_ToLoad = !fl_ToLoad;
    }

  6. #6
    Junior Member
    Join Date
    Dec 2010
    Posts
    11
    edit sorry

    IGNORE

    fl_Loader.load(new URLRequest("page1.swf", 1));

    im trying to load it to level 1 this doesnt work

    should read

    fl_Loader.load(new URLRequest("page1.swf"));

    this works but replaces my site with the loaded swf

  7. #7
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    a Loader object exists within the existing swf. you can load and unload images using a Loader object. it does not open new windows.

    the navigateToURL method is just like an html link. you can either redirect the existing window, open a new window, or target a frame. the second argument of navigateToURL specifies the window to use:

    PHP Code:
    var request:URLRequest = new URLRequest("http://google.com");
    navigateToURL(request"_blank"); 
    the above would open google in a new window.

    you cannot open a flash player window on a client machine. you might be able to get it to work locally, but it won't work from a browser.

    also, some browser won't recognize ".swf" files and will just open up blank - swf files should be housed in html documents.

  8. #8
    Junior Member
    Join Date
    Dec 2010
    Posts
    11
    ah right ok, so swf embedded in html it is then. right ive made mypage.html file with the swf embedded in it, this is the code now

    var request:URLRequest = new URLRequest("mypage.html");

    myButton.addEventListener(MouseEvent.CLICK, cHandler);
    function cHandler(event:MouseEvent):void

    {
    navigateToURL(request, "_blank");

    }

    again all this does when i press my button is open a firefox windows showing my google homepage, not the web page im trying to open. im not getting any popup messages etc, it just opens a default homepage.

  9. #9
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    that code is correct. the only thing i can guess is that "mypage.html" isn't being found, and for some reason your browsers showing google rather than a missing file.

    try this:

    1. create a new fla.
    2. drag a button to the stage.
    3. name the button "myButton"
    4. take the code you posted above, with one change: instead of "mypage.html" put in "http://board.flashkit.com/board/showthread.php?t=819631" (the url of this thread), and put it in the actions panel of frame 1.
    5. test movie and click the button - it should open up a new browser window showing this thread.

    i tried the above just to make sure i wasn't missing something silly like a typo in what you pasted, and it works fine.

  10. #10
    Junior Member
    Join Date
    Dec 2010
    Posts
    11
    thanks very much for the help, im choc a block in work so ill have to try this this evening when i get home, again i appreciate your time,thanks.

  11. #11
    Junior Member
    Join Date
    Dec 2010
    Posts
    11

    works!!

    yes it opens the window perfect and loads this thread, so its an issue with my path then i take it. i have the fla file saved in the same folder as my html file so i assumed all i had to do was put the name of the html in and it would find it?

  12. #12
    Junior Member
    Join Date
    Dec 2010
    Posts
    11
    in dreamweaver i have just made a simple page with txt no flash embedded, that doesnt open either, web addresses open, perhaps i should upload it online and see if it opens then rather than locally.

  13. #13
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    if you're using "test movie", the path needs to be relative to the swiff. if you're running the calling swf from an html document, the path needs to be relative to the html document (not the swiff). the location of the fla isn't important.

  14. #14
    Junior Member
    Join Date
    Dec 2010
    Posts
    11
    ive uploaded the file online and it works fine opens straight away, firefox doesnt seem to like the page turning, ie it works 100%. thank you somuch for your help today.

  15. #15
    ___________________
    Join Date
    May 2004
    Posts
    3,174

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