• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Open another SWF file in the same browser window?

Engaged ,
May 17, 2014 May 17, 2014

Copy link to clipboard

Copied

I have designed a web site, the first page is HTML. How do I code a button to load another an SWF file in the same web browser window?

TOPICS
ActionScript

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 22, 2014 May 22, 2014

The example site does not use Flash.  If you want it to function exactly the same then you do not want to use Flash.

If you want a similar functionality then you can just use the navigateToURL() function to open the new page with the site swf embedded in it.

Explaining AS3 Button Code
--------------------------

Let's say you create a button symbol.  Since it is a button, it is already a self animating object that will react to mouse interactions, but only visually at this stage.  The first thing y

...

Votes

Translate

Translate
LEGEND ,
May 17, 2014 May 17, 2014

Copy link to clipboard

Copied

Where is this button located?  Since you say "another" what is the relationship between the first and the second that you want to load?  Where will the second be loaded?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 21, 2014 May 21, 2014

Copy link to clipboard

Copied

The button on located on my splash/introduction page. It's an SWF file that is embedded in an index.html file.

So what I would like to happen is that when the button on the splash/introduction page is touched, it goes to the next page/SWF file to show the actual contents of the website within the same browser to function exactly the same as this web site http://www.samgilbey.com/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 22, 2014 May 22, 2014

Copy link to clipboard

Copied

Anyone know where I can find the ActionScript for the question I've asked?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 22, 2014 May 22, 2014

Copy link to clipboard

Copied

The example site does not use Flash.  If you want it to function exactly the same then you do not want to use Flash.

If you want a similar functionality then you can just use the navigateToURL() function to open the new page with the site swf embedded in it.

Explaining AS3 Button Code
--------------------------

Let's say you create a button symbol.  Since it is a button, it is already a self animating object that will react to mouse interactions, but only visually at this stage.  The first thing you need to do to make it useful code-wise is to assign it a unique instance name.  So you drag a copy of it out to the stage from the library, and while it's still selected, you enter that unique instance name for it in the Properties panel... let's say you name it "btn1"


In AS3, to make a button work with code, you need to add an event listener and event handler function for it.  You might need to add a few (for different events, like rollover, rollout, clicking it, but for now we'll just say you want to be able to click it to get a web page to open.  In the timeline that holds that button, in a separate actions layer that you create, in a frame numbered the same as where that button exists, you would add the event listener:


btn1.addEventListener(MouseEvent.CLICK, btn1Click);

The name of the unique function for processing the clicking of that button is specified at the end of the event listener assignment, so now you just have to write that function out:


function btn1Click(evt:MouseEvent):void {

   var url:String = "http://www.awebsite.com/awebpage.html";

   var req:URLRequest = new URLRequest(url, "_self");   // "_self" indicates to open in the same window

   navigateToURL(req);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 22, 2014 May 22, 2014

Copy link to clipboard

Copied

Thanks, I'll try this!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 16, 2017 Apr 16, 2017

Copy link to clipboard

Copied

LATEST

I have followed the above suggestion to open a second swf in the same window as my swf Table of Contents. I have about 50 more buttons to code, but I can't get past No1. Here is my code:

No1.addEventListener(MouseEvent.CLICK,No1Click);

function No1Click(event:MouseEvent):void {

   var url:String = "http://www.rhythmbee.com/programs/8409/download";

   var req:URLRequest = new URLRequest(url,"_self");   // "_self" indicates to open in the same window

   navigateToURL(req);

}

I consistently get this message in the Output pane.

TypeError: Error #2007: Parameter type must be non-null.

  at flash.events::EventDispatcher/addEventListener()

Any help is greatly appreciated.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines