View unanswered posts | View active topics


Reply to topic  [ 6 posts ] 
Quitting Flash player via ExternalInterface 
Author Message
Member

Joined: Thu May 15, 2008 7:36 pm
Posts: 605
Location: Baltimore, MD
Post Quitting Flash player via ExternalInterface
I know ExternalInterface.call() is suppose to be used instead of fscommand, but I'm hitting an issue with getting it to work in my engine.

If I call the following I have the Flash player shutdown properly:
Code:
fscommand("quit");


But if I try the "proper" way I get a weird hang in the player:
Code:
ExternalInterface.call("quit");


Has anyone else been able to get the player to quit cleanly with ExternalInterface?

_________________
http://tronster.com


Sun Sep 12, 2010 1:32 am
Profile WWW
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 10749
Location: Paris, France
Post Re: Quitting Flash player via ExternalInterface
I don't think you can simulate fscommand using ExternalInterface.

In AS1/2 getURL can be used as an alternative:
getURL("FSCommand:action", "param");

so I suppose it should also work that way using navigateToURL.


Sun Sep 12, 2010 6:13 pm
Profile WWW
Member

Joined: Thu May 15, 2008 7:36 pm
Posts: 605
Location: Baltimore, MD
Post Re: Quitting Flash player via ExternalInterface
@Philippe I thought ExternalInterface.call() 's purpose was to supersede fscommand. At least with my day job, it's handled AS2 fine; I figured with AS3 it would be the same and it's just a bug in the player that "quit" is not
recognized.

http://www.adobe.com/livedocs/flash/9.0 ... html#call()

I also thought that maybe it was a limitation (that fscommand didn't have to adhere to) due to "Network Services" turned on but turning this off still resulted in the player locking up.

_________________
http://tronster.com


Tue Sep 14, 2010 2:35 am
Profile WWW
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 10749
Location: Paris, France
Post Re: Quitting Flash player via ExternalInterface
Well you can use fscommand to call a user-defined javascript function to handle custom commands. It's clumsy but it kind of works :)

However 'quit', 'fullscreen', etc. are handled specially by the host and AFAIK you can not send this commands using ExternalInterface.

That said ExternalInterface is really powerful, I encourage you to dig into it ;)


Tue Sep 14, 2010 8:13 am
Profile WWW
Member

Joined: Wed Jun 20, 2007 8:09 am
Posts: 331
Post Re: Quitting Flash player via ExternalInterface
Hi,

as you are talking about the use of ExternalInterface:
With ExternalInterface you can execute any javascript code you want (in browser of cource ;)). It's also superior to the well known navigateToURL because i.e.
Code:
navigateToURL(new URLRequest("javascript:history.back()", "_self"))
is buggy in in Internet Explorer but
Code:
ExternalInterface.call("history.back()")
works nicely in all browsers :D

Lg
warappa

_________________
Practice always defeats theory


Tue Sep 14, 2010 9:10 am
Profile WWW
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 10749
Location: Paris, France
Post Re: Quitting Flash player via ExternalInterface
Actually it should be:
Code:
ExternalInterface.call("history.back");

You had parents after 'history.back' which isn't correct - although it may somewhat work.

Technically, first parameter of .call() will be eval'ed in Javascript - a function is expected. This function will be called with any number of additional parameters that you can pass in ...rest to .call().

You can basically provide anything to be eval'ed, which allows you to do some nifty JS injection (bonus CDATA trick here for defining a multiline string):
Code:
var src:String = <![CDATA[
  function(a, b) {
    alert("this function was injected, then passed "+a+" and "+b+" as parameters");
  }
]]>;
ExternalInterface.call(src, "Hello World", 42);


Wed Sep 15, 2010 6:48 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.