Skip to main content
Participating Frequently
August 19, 2009
Answered

Problem closing popup window in flash player 10.0.32.18

  • August 19, 2009
  • 1 reply
  • 3054 views

Hello,

I'm new to the forum so please bear with me. I posted this in the actual "Flash" forum yesterday but I realized afterward that the ActionScript forum would be a better place to post the question (sorry about that). I'm a web designer but I don't use a lot of Flash. I'm sure this will change as time goes on. For now, I'm still using an old version of Flash MX on my Mac - Flash MX version 6. But I don't think this has anything to do with the problem I'm experiencing. I designed a flash animation for my wife's website back in 2004 and it has always worked perfectly up until installing the most recent Flash Player 10.0.32.18 just a few days ago. Here's the problem:

On the main page of my wife's website, we have a special link called "view presentation". When you click on that link, a smaller, new browser window pops up in front of the main page (the window sits "over top" of the main page - a typical pop up window). Inside of this new pop up window is the flash animation (the actual swf file). Inside of the HTML code for the pop up window, I have coded the following javascript:

function closeWin() {

   if (document.images) {

     self.close();

   }

}

The above script, closeWin() is called from a button called "Quit" that the user clicks on in the actual swf file inside of the pop up window. Here is the code from the swf ActionScript:

on (release) {

    stopAllSounds();

    getURL("javascript:closeWin();", "_self");

}

This has always worked perfectly right up to Flash Player version 10.0.22.87 - the window closed as soon as the user clicked on the button. But now, with the most recent Flash Player 10.0.32.18 installed, it no longer works. The pop up window no longer closes.

Obviously, something has changed in this latest version of Flash Player 10.0.32.18 which is preventing this from working. Does anyone have any ideas on how I can fix this?

Any help would be greatly appreciated. Thank you so much,

Mike

This topic has been closed for replies.
Correct answer

Actually, the more I think about this, the more I think that your alert box that pops up is what the difference is. So having said that, do you have your getURL() function coded to put the alert up first and then call the closeWin() function afterward in the HTML?

I think if I add an alert into the getURL function that says something like "Are you sure you want to close the window?" with a yes/no, then it will work.

I have it coded like this right now but I don't know exactly where to put the "alert" call:

getURL("javascript:closeWin();", "_self");

Thanks again,

Mike


I actually had a mistake on my last test. It actually embedded the original swf, instead of the one with external javascript. So here are the tests I have so far:

  1. All in flash with alert: http://lhsmath.co.cc/js_selfclose.html
  2. JavaScript with alert: http://lhsmath.co.cc/js_selfclose2.html
  3. Javascript without alert: http://lhsmath.co.cc/js_selfclose3.html

I think it's kind of weird for the alert to make a difference. In fact, for the third test, even without the alert, it still works for me. But, if you want to try it anyway, you can either add it to the JavaScript in the HTML as: alert("Really? You really want to do that?"); or in ActionScript:

getURL("javascript:alert('Really? You really want to do that?'); closeWin();", "_self");

Could you possibly send a link to the problematic page? Or at least a simplified version to see if there could possibly be anything else interfering?

1 reply

August 19, 2009

Are you sure it's a Flash player issue? I tried a similar script (seen at http://lhsmath.co.cc/js_selfclose.html ):

onMouseDown = function(){
getURL('javascript:alert("Hi!");self.close();');
}

And it seemed to work both on 10.0.22.87  and 10.0.32.18. Using a function closeWin() defined in the HTML gave the same result.

I would try using "javascript:alert('test');" to see if the javascript is getting through. Then check if self.close() works. If it is, there's got to be something wrong with "document.images". On the chance that all of them fails, perhaps it is a result of security changes? In that case, you have a couple of other options. See: http://www.adobe.com/devnet/flash/articles/external_interface_print.html

Participating Frequently
August 19, 2009

Thanks so much for your help - in your example, I looked at the actual HTML code of your page at:

http://lhsmath.co.cc/js_selfclose.html

There is no javascript anywhere in your HTML code that I can see. My pop up window has an actual javascript "closeWin()" (which is just basically the javascript command "self.close" called after a few checks) in the HTML. My swf file calls that javascript externally, I guess - through "getURL()" in the swf file. There seems to be a problem with the swf file communicating with the javascript in the HTML of the pop up window - almost like flash player 10.0.32.18 is preventing the "self.close" portion from working (security changes?). I took out the "document.images" part of the javascript code but it makes no difference.

We have one computer here running flash player 10.0.22.87 and it works fine on that machine but on my computer running flash player 10.0.32.18, the window just won't close.

It looks like I may have to use the ExternalInterface class but I don't think Flash MX version 6 can handle that?

Also, I never coded allowScriptAccess in the HTML pop up code but the documentation you pointed me to says that if allowScriptAccess is not explicitly specified by an HTML page, the default value for the embedded SWF file is set to "sameDomain" in Flash Player 8 and to "always" in earlier versions so this shouldn't make any difference.

I'm at a real loss. Can you try adding the same closeWin() javascript that I'm using into your HTML again and call that javascript from your swf file using getURL to see if does in fact, work under 10.0.32.18? I can't see how it would work for you but not for me.

Thanks again,

Mike

August 19, 2009

Here it is with JavaScript in the HTML: http://lhsmath.co.cc/js_selfclose2.html

Wait, does that mean, that my version worked without the JavaScript in the HTML on your problematic machine? If this is the case, then I am puzzled. Could you provide me with a link to your wife's site?

ExternalInterface is not available for Flash MX so that won't work for you, unforunately.

Perhaps it is not the flash player, but some other setting specific to that particular machine? Try viewing the site from a different machine that is upgraded. Or, see if the problem persists when you downgrade the Flash Player: http://kb2.adobe.com/cps/142/tn_14266.html