TwelvestoneFlash

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


Sign in

  • Waiting for Godot ( 720 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 4.8 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.8 k posts )
    general front end design an...
  • Back End ( 9.6 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
arigato
 
2009-06-12

"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
 
2009-06-13

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.

arigato
 
2009-06-14

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

Storm
 
2009-06-14

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

arigato
 
2009-06-14

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

Storm
 
2009-06-14

ooh that sucks

arigato
 
2009-06-14

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
 
2009-06-14

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
 
2009-06-14

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
 
2009-06-15

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

arigato
 
2009-06-15

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. k

Storm
 
2009-06-15

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

arigato
 
2009-06-15

A reasonable thought. I will check into it.

arigato
 
2009-06-15

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
 
2009-06-15

now you have to like me k

ExternalInterface is really only the best for triggering JS functions.

Glad you got it.

arigato
 
2009-06-15

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

I owe you one. k

Storm
 
2009-06-15

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
 
2009-06-15

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

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

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