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

externalinterface crashing browsers

New Here ,
Jun 28, 2012 Jun 28, 2012

Copy link to clipboard

Copied

Hi,

I have a client that wanted a flash slideshow that would go to various pages on her website when clicked.  I'm using externalinterface to call a simple window.location(url, "_self") within the browser.  Half of the time the browser hangs for about 2 seconds and then loads the page.  CPU usage spikes during those 2 seconds so something's going on.  The other half of the time the browser hangs for a while (30 seconds) CPU spike the whole time, and eventually I get the following Unresponsive Script warning:

A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete.

Script: resource://firebug/firebug-service.js:4290

I use firebug on Firefox as a debugger for development, but have tried disabling firebug to see if that was the root of the problem, and the problem persists without the plugin installed . . .  This problem is also happening in all the other major browsers.  When firebug IS enabled, I get the following errors in it's console:

too much recursion

jQuery is not defined

(the "jQuery is not defined" then is repeated over and over a couple hundred times . . . )

Choosing to stop the script doesn't stop the browser from hanging.  Instead the Unresponsive Script warning pops up again after another 30 second hang.  Even if the browser DOES manage to load the page that the window.load() call through the ExternalInterface, the browser continues to hang, even on the next page.  I'm using jQuery on the page to manage some drop-down menues, and it's otherwise not interacting with Flash in any way (the javascript call through ExternalInterface is not using jQuery, the window.open() is a basic javascript function that doesn't need jQuery to run).

Any thoughts? 

Here is my code:

private function stage_clicked(e:MouseEvent):void{ // IF THE CLICK MAKES IT TO THE STAGE, USER IS CLICKING ON AN AD, NOT A BUTTON . . .

     e.stopImmediatePropagation();  // STOP MOUSE CLICK PROPOGATION

     try {

          if (ExternalInterface.available){

               ExternalInterface.call("window.open","www.yahoo.com", "_self");

          } else {

               trace("no external interface available.");

          }

     } catch (e:Error) {

          trace("error: " + e.message);

     }

}

TOPICS
ActionScript

Views

2.5K

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
Community Expert ,
Jun 30, 2012 Jun 30, 2012

Copy link to clipboard

Copied

the problem is in your html page or a linked js page.  copy and paste that code.

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 ,
Jul 02, 2012 Jul 02, 2012

Copy link to clipboard

Copied

Hi kglad,

thanks for the response.  I've built a test page and have removed all other javascript from that page to eliminate any conflicts there, and am still experiencing this issue.  I'm copy-and-pasting the JS code to embed the Flash object straight from the file created with a File > Publish operation within Flash.  Here is the relevent code per your request:

(in the page head):

<script language="javascript">AC_FL_RunContent = 0;</script>

<script src="js/AC_RunActiveContent.js" language="javascript"></script>

(in the page body):

<script type="text/javascript">

  if (AC_FL_RunContent == 0) {

    alert("This page requires AC_RunActiveContent.js.");

  } else {

    AC_FL_RunContent('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0',

    'width','690',

    'height','334',

    'wmode','opaque',

    'src','../ad_rotator_02',

    'quality','high',

    'pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash',

    'movie','../ad_rotator_02'

);

}

</script><noscript>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="690" height="334" wmode="opaque">

<param name="movie" value="../ad_rotator_02.swf" />

<param name="quality" value="high" />

<param name="wmode" value="opaque" />

<embed src="../ad_rotator_02.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="690" height="334" wmode="opaque"></embed>

</object></noscript>

(in the Flash object):

private function stage_clicked(e:MouseEvent):void{

  e.stopImmediatePropagation();

  try {

    if (ExternalInterface.available){

      ExternalInterface.call("window.open", "http://www.yahoo.com", "_self");

    } else {

      navigateToURL(new URLRequest("http://www.yahoo.com"), '_self');

    }

  } catch (e:Error) {

    trace("error: " + e.message);

  }

}

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
Community Expert ,
Jul 03, 2012 Jul 03, 2012

Copy link to clipboard

Copied

comment out that call:

ExternalInterface.call("window.open", "http://www.yahoo.com", "_self");

and retest.   same problem?

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 ,
Jul 03, 2012 Jul 03, 2012

Copy link to clipboard

Copied

Hi Kglad, thanks again for the help.

Removing ExternalInterface from my script and relying on URLRequest results in page loads on all browsers except Internet Explorer (using version  8 on a Windows 7 system).  IE throws a javascript error when clicking on the stage of the Flash object:

'null' is null or not an object

ExternalInterface works great with IE.  Firefox hangs for about 1 second before the window.location() kicks in and loads up the new page.  Chrome hangs for 4-5 seconds before loading the new page.  Safari hangs for several seconds, then throws an unresponsive script message.  After clicking on the button to stop the unresponsive script, the new page is loaded.

Here are two samples if you care to look:

fitnessforyougym.com/indext1.html - uses URLRequest, works in FF, Chrome, and Safari, but not in IE.

fitnesforyougym.com/indext2.html - uses ExternalInteface, works in IE, hangs for a second in FF, hangs for several seconds in Chrome, hangs and throws unresponsive script message in Safari

It would be really nice if this would just work across all 4 of these browsers, otherwise I guess I'll have to do a bunch of browser sniffing and serve up 2 versions of the Flash widget, which would be a pain.

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
Community Expert ,
Jul 03, 2012 Jul 03, 2012

Copy link to clipboard

Copied

you have typos in, at least, the 2nd url

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 ,
Jul 03, 2012 Jul 03, 2012

Copy link to clipboard

Copied

sorry, forgot an 's' in the 2nd url's domain name, correct urls are:

fitnessforyougym.com/indext1.html

fitnessforyougym.com/indext2.html

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
Community Expert ,
Jul 03, 2012 Jul 03, 2012

Copy link to clipboard

Copied

am i supposed to click something to see the problem?

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 ,
Jul 03, 2012 Jul 03, 2012

Copy link to clipboard

Copied

A click to the stage should cause the pageload.  The buttons on the left have stopImmediatoPropogation on them to prevent the mouse click event from propogating up to the stage.  The stage has the above mouse event listener on it, other than instead of going to yahoo it loads a URI depending on the current ad.  Again, indext1.html uses URLRequest to do the page load while indext2.html uses ExternalInterface to call window.location() approach.

.

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
Community Expert ,
Jul 04, 2012 Jul 04, 2012

Copy link to clipboard

Copied

LATEST

i see the problem but am unable to help without investing significant time including downloading your files. 

perhaps someone else can help.

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