Forums: Flash:

 

close popup from internal link, load new url in parent (as4)

first
 

arigato close popup from internal link, load new url in parent (as4)

"website.com" is a dummy url. I don't have access to the js file that opens the popup so I have no idea what the parent page's name is. I'm doing this wrong, I know.

function mouseUpHandler(event:MouseEvent):void {
var url:String = "http://www.website.com";
ExternalInterface.call("window.opener.location.href='" + url + "'");
ExternalInterface.call("self.close()");
}


Closing the popup works, but not the url load,even if I comment out the line that closes the popup.

Thoughts?

 

mystic_juju

ExternalInterface makes calls to external functions, so the best approach would be to have a js function that will open the url and then you call that function from within flash, passing the 'url' parameter to that function.

A tale that begins with a beet will end with the devil
quote
 

arigato

I realize that, but only have access to the flash file.
I'm not allowed to modify any other file on the site.

 

Storm

not even the html? the JS function can live in the html file that calls the swf.

 

arigato

Nope, I'm only allowed to modify the swf.

 

Storm

ooh that sucks

 

arigato

Yes, yes it does. In any case, window.opener.location.href works in javascript if it's embedded in the popup & called from an html link, any reason it wouldn't work in Flash?

I know how to do it with getURL but of course this isn't as2 any more, I was under the impression ExtrnalInterface.cal was the method for using javascript now.... please do correct me if I'm wrong!

 

Storm

You're right that ExternalInterface is the correct communication method with JS; however, Flash has always been held into different security schemes than anything else. That means you can't (as far as I understand) just write willy-nilly JS scripts due to the security restrictions. There's a difference triggering JS functions and writing the JS in Flash. Maybe that's why it doesn't work.

 

arigato

OK, I'll buy that. so given what I want to do, do you have any suggestions other than get access to the other files?
Can it, unlike pinball, be done in Flash?

 

Storm

not sure.....

gotoandlearnforum.com/viewtopic.php?f=29&t=20762
He's using URLRequest to pass a JS function...try that.

 

arigato

Interesting... though my code achieves what he's trying to do:

function mouseUpHandler(event:MouseEvent):void {
ExternalInterface.call("self.close()");
}


In any case, I posted my question there too, let's see if I get any workable replies.
wink

 

Storm

My only thought was maybe the ExternalInterface class passes info different than a straight URLRequest string.

 

arigato

A reasonable thought. I will check into it.

 

arigato

saints alive!

function mouseUpHandler(event:MouseEvent):void {
var jscommand:String = "window.opener.location='http://www.website.com';self.close();";
var req:URLRequest = new URLRequest("javascript:" + jscommand + " void(0);");
navigateToURL(req, "_self");
}


Works a charm. Thanks for the tips, Storm.

 

Storm

now you have to like me smile

ExternalInterface is really only the best for triggering JS functions.

Glad you got it.

 

arigato

Well, you're still from Edmonton but you do give good Flash advice.
big grin

I owe you one.
wink

 

Storm

not from Edmonton....never lived in Edmonton....never will.....I'm southern.

and I will get there to visit you one day. I keep saying I'm coming there. Cali is too far from all you eastern-type shenanigans.

 

arigato

Ah, I had you pegged for a Deadmontonian, my bad.
You're always welcome to pull up a seat at the bar.
beer

 
first
 

Forums: Flash: close popup from internal link, load new url in parent (as4)

 
New Post
 
You must be logged in to post