17 Replies Latest reply on Jul 3, 2007 10:46 PM by kglad

    Opening URL Targets with AS3

    johnd59898678 Level 1
      I have the following code on my Actions Frame 1 (copied and modified from the Flash CS3 Help Files):

      function loadPageFrame(event:MouseEvent):void
      {
      var myURL:URLRequest = new URLRequest(" http://www.adobe.com/");
      navigateToURL(myURL);
      }
      Btn1.addEventListener(MouseEvent.CLICK, loadPageFrame);

      This code is working great, but not exactly what I need - I need it to load the target URL into a secondary HTML Frame on my site. My top FRAME is a FLASH AS 3 SWF Navigation Header. This is where the code referenced above resides. The bottom frame (labeled "content.html") is my target. Can anyone help me with this?
        • 2. Re: Opening URL Targets with AS3
          johnd59898678 Level 1
          kglad,

          Thanks for the quick response - figured it would be something simple. I will not be able to try this until tomorrow, but this looks logically correct and should work.

          Thanks again!!
          • 3. Re: Opening URL Targets with AS3
            kglad Adobe Community Professional & MVP
            you're welcome.
            • 4. Opening URL Targets with AS3
              johnd59898678 Level 1
              Well , almost, but not quite there.

              This is the new code on my FLASH AS 3.0 button...

              function loadPageFrame(event:MouseEvent):void
              {
              var myURL:URLRequest = new URLRequest("CorporateOverview.html");
              navigateToURL(myURL,"mainFrame");
              }
              Btn1.addEventListener(MouseEvent.CLICK, loadPageFrame);

              RESULT:
              The button link is now loading the page "CorporateOverview.html" into a new browser window (same result as using "_blank") instead of opening the page in the "mainFrame" as hoped for. My frameset has 3 frames top to bottom. The top frame contains all my Flash navigation and it should always be visible, the middle frame is the dynamic frame that will have over 100 HTML pages being loaded into it (if I can get this button linking to work properly). And there is also a static bottom footer frame.

              Since the button link is working - that is good news, but it just is not sending the URL to the proper frame target? Any other ideas?
              • 5. Re: Opening URL Targets with AS3
                johnd59898678 Level 1
                I just looked up "navigateToURL" in the Flash CS3 Help file and is says this:

                navigateToURL(request:URLRequest, window:String = null):void
                Opens or replaces a window in the application that contains the Flash Player container (usually a browser).

                I don't want to OPEN or REPLACE a window in the browser. I want to have a button inside a Flash SWF in one frame LOAD a new HTML page into another frame within the same frameset. I see this done on sites everyday and after working with Flash for 5 years I still cannot figure out how they do it

                What I am trying to do is very similar to:
                http://www.katzkin.com/05/FC/mainFS.html
                Their navigation stays frozen in the top frame and clicking on those buttons loads new pages in the middle frame - I see this several times a day everywhere and I still cannot figure this out?
                • 6. Re: Opening URL Targets with AS3
                  kglad Adobe Community Professional & MVP
                  the code i gave is correct. if you're opening a new window you probably have mis-typed your frame name.

                  for specific help, copy and paste (using the attach code option) your html file that contains your frame set information.
                  • 7. Re: Opening URL Targets with AS3
                    johnd59898678 Level 1
                    OK - that makes sense, but still not sure how I do that. I was not including any name for the "frameset" - just the frame itself".

                    My Frameset name is " KentFrameset.html " and my frame target name is " mainFrame ".

                    Can you tell me in this instance exactly how this line ( navigateToURL(myURL,"yourTopFrame" ) should read? - just not sure of the syntax for referencing a frame inside a frameset?

                    If I can get this one to work I should be able to figure out the rest. I am not sure what you mean by (using the attach code option)?
                    • 8. Re: Opening URL Targets with AS3
                      kglad Adobe Community Professional & MVP
                      copy the html file that contains your frameset tag and use the "Attach Code" button (after clicking reply - not quick reply) to display that html code. for example:

                      • 9. Re: Opening URL Targets with AS3
                        johnd59898678 Level 1
                        Here it is...
                        • 10. Re: Opening URL Targets with AS3
                          kglad Adobe Community Professional & MVP
                          there's no problem with your coding.

                          you can zip your html file with your frameset tags and your fla and i'll test them.
                          • 11. Opening URL Targets with AS3
                            johnd59898678 Level 1
                            kglad,

                            Thank you for the offer, but apperntly this just can't be done yet in AS3.0 - it should not be this involved. I have had other programmers that have looked at this today and they too are stumped and can't believe that something so common does not have at least one example in the Flash CS3 Help files? I am apparently not the only one that cannot make this work ( http://www.kirupa.com/forum/showthread.php?t=266225 ). I guess I will just write-off the last month of work I did trying to build this nav menu in AS 3 and start over in AS 2 - where I know this can be done. What a waste of a month!
                            • 12. Re: Opening URL Targets with AS3
                              kglad Adobe Community Professional & MVP
                              i have no trouble getting your code to work wifth firefox. testing with ie7 shows problems.

                              i have the same flash player version in both browsers so this is an ie7 issue.
                              • 13. Opening URL Targets with AS3
                                johnd59898678 Level 1
                                I cannot get it to work in any of the latest versions of Mac browsers (Safari, Firefox or Opera - Mac dropped IE) - opens a new SEPARATE window in all three. Of course, if it does not work in IE on the PC I am hosed.
                                • 14. Re: Opening URL Targets with AS3
                                  johnd59898678 Level 1
                                  kglad,

                                  STOP THE PRESS. I may have criticized too soon. As a ditch effort I uploaded all my test files to a remote server online AND YOUR CODE WORKS in all the latest Mac browsers!!! Apparently my previewing problem is in using Dreamweaver CS3 - Dreamweaver is not loading the page in the correct frame locally (big surpriise as many things don't display correctly in Dreamweaver - the Not-So-WYSIWYG editor).

                                  Here is my Test URL " http://www.thekentcompanies.com/TEST/Pages/ " . This is still in the early development stages, but if you go to KENT CORPORATE and rollover that button and then click the first button in the sub-meny "OVERVIEW" - that indeed opens up a new page in the main content frame!! This is the only button I have activated so far.

                                  Since I do not have a PC (Mac only here) - I do not know if this will display you IE 7 issue - but at least it is working on Mac browsers!

                                  • 15. Re: Opening URL Targets with AS3
                                    kglad Adobe Community Professional & MVP
                                    i'm on a pc and tested your website with firefox 2.0 and ie7. using both browsers, the lines below appeared centered below the flash menu:



                                    Kent Overview Test Page



                                    This is a Test Page to check for Frame Loading...
                                    • 16. Re: Opening URL Targets with AS3
                                      johnd59898678 Level 1
                                      Thanks for taking the time to test this on the PC. If what you say is the case, it sounds like all is working properly then. If clicking that Flash button loaded the text HTML test page you saw (replacing the animation) then it is indeed loading into the proper frame! All I have to do now is add the code and linked pages for all the buttions.

                                      I guess you are saying that the IE on PC frames bug you discovered has not presented itself on this test site?

                                      Thanks again for all your assistance - apparently my biggest problem was with Dreamweaver CS3 and the way it handles this type of linking on the development platform rather than with Flash itself - your code was apparently fine all along.
                                      • 17. Re: Opening URL Targets with AS3
                                        kglad Adobe Community Professional & MVP
                                        correct. i had a problem with ie7 when tested locally. firefox works fine locally.

                                        the only online testing i did was with your site and both ie7 and firefox worked as expected opening your test page in the lower frame (not in a popup page).