views:

221

answers:

1

This is the Class I'm using to bypass the popup blocker.

This is the function to call to the class function

function linkHandler(e:MouseEvent):void{
popup.ChangePage(linksURLArray[e.currentTarget.name], "_self");
}

this is the class.

package com.dbd.external {
    import flash.external.ExternalInterface;
    import flash.net.*;
    public class PassPopup {
        public function ChangePage(url:*, window:String = "_blank"):void {
            var req:URLRequest = url is String ? new URLRequest(url) : url;
            if (!ExternalInterface.available) {
                navigateToURL(req, window);
            } else {
                var strUserAgent:String = String(ExternalInterface.call("function() {return navigator.userAgent;}")).toLowerCase();
                if (strUserAgent.indexOf("firefox") != -1 || (strUserAgent.indexOf("msie") != -1 && uint(strUserAgent.substr(strUserAgent.indexOf("msie") + 5, 3)) >= 7)) {
                    ExternalInterface.call("window.open", req.url, window);
                } else {
                    navigateToURL(req, window);
                }
            }
        }
    }

} 

I'm working locally, http://localhost/ and trying to link externally to another domain.

A: 

Be sure to include in your AS code. ExternalInterface requires the allowDomain to be set when HTML-SWF cross-scripting is performed even though it’s local to your browser.

System.security.allowDomain("*");

Plus be sure to add the following in your Flash embed HTML

allowscriptaccess="always" 

If that does not work then add a crossdomain.xml like the following:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"&gt;
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>

And add the following to your AS code:

System.security.loadPolicyFile("http://yourdomain.com/crossdomain.xml");
Todd Moses
Would i put this into my main AS class or the Popup CLass?
DesignedByDave
I just tried it out. It doesn't work :(
DesignedByDave
Put it in the main as class
Todd Moses
Add allowscriptaccess="always" to the Flash embed tag in the HTML too
Todd Moses
I'm trying this online right now on a test server, and i'm still getting the popup blocker. It doesn't like when i use _blank
DesignedByDave
This answer is for a completely different problem and won't do anything for popup blockers. I'm still searching for the answer to this problem myself.
JoeCoder
The issue that I was trying to help with is the one with External Interface being called on local host. It turns out that there is another issue with the code given in the question. If you want an answer to your question then post it with your code.
Todd Moses