Skip to main content
Inspiring
July 2, 2007
Question

Opening URL Targets with AS3

  • July 2, 2007
  • 9 replies
  • 1544 views
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?
This topic has been closed for replies.

9 replies

kglad
Community Expert
Community Expert
July 4, 2007
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).
kglad
Community Expert
Community Expert
July 4, 2007
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...
Inspiring
July 4, 2007
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.
Inspiring
July 4, 2007
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!
kglad
Community Expert
Community Expert
July 4, 2007
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.
Inspiring
July 4, 2007
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.
kglad
Community Expert
Community Expert
July 3, 2007
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.
kglad
Community Expert
Community Expert
July 3, 2007
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.
Inspiring
July 3, 2007
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)?
kglad
Community Expert
Community Expert
July 3, 2007
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:

Inspiring
July 3, 2007
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?
kglad
Community Expert
Community Expert
July 2, 2007
you're welcome.
Inspiring
July 3, 2007
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?
Inspiring
July 2, 2007
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!!
kglad
Community Expert
Community Expert
July 2, 2007
: