This method handles the process of calling a javascript popup using the window.open function from a flash movie (AS3) embedded in a web page - if this fails (due to aggressive popup blocking, e.g. Safari) a normal window is opened, as if a link with target='blank' was clicked.
Here's how it works:
1. The .swf uses ExternalInterface.addCallback to create a path back into flash, allowing a window to be opened through normal (navigateToURL) methods.
2. The .swf uses ExternalInterface.call to run a method of an instance of the PopupFromFlash javascript class on the page that the .swf is embedded in - this function attempts to create a popup using window.open. If it fails, it calls back to the .swf using the path established in the first step.
Optionally, a random seed may be used as a unique title for the new window, forcing most browsers to open the link in a new window every time, rather then re-using previously popped windows.
This will only work if the version of Flash supports ExternalInterface, and the alternate to window.open will only work if the browser is able to reach the embedded flash through document.getElementById - which means that nearly all modern browsers will support this method.
The PopupFromFlash.js includes an instruction to add an instance of PopupFromFlash to the page's DOM named popupFromFlash - if for some reason this conflicts with an existing object, you can edit PopupFromFlash.js to instantiate PopupFromFlash as something else, but make sure to edit PopupFromFlash.as as well so that 'popupFromFlash.openWindow' on line 20 accurately reflects the name of that new instance.
This method was inspired in part by Ali Mills' Workaround for Safari Blocking Flash Initiated Pop Ups, although it's been modularized and slimmed down. Thanks, Ali!