ActionScript: fscommand vs ExternalInterface

3.1k views Asked by At

In ActionScript you have two options to communicate to the host. (In my case a .NET app that uses AxInterop.ShockwaveFlashObjects.dll to host the flash movie)

fscommand(String, ...);

ExternalInterface.call(String, ...);

what are the main differences between the two?

Could it be that fscommand arrives with a little delay on the host side? (i.e. it is not blocking and could therefore get mixed up with ExternalInterface calls?)

2

There are 2 answers

0
net.uk.sweet On BEST ANSWER

ExternalInterface is a direct replacement for fscommand, which was the old method (pre Flash player 8) of communicating between Flash and the container application (see Adobe documentation).

From the documentation again, the advantages of ExternalInterface over fscommand are as follows:

  • You can use any JavaScript function, not only the functions that you can use with the fscommand() function.
  • You can pass any number of arguments, with any names; you aren't limited to passing a command and a single string argument. This gives the external API much more flexibility than fscommand().
  • You can pass various data types (such as Boolean, Number, and String); you are no longer limited to String parameters.
  • You can receive the value of a call, and that value returns immediately to ActionScript (as the return value of the call you make).

If you're targeting Flash Player 8 or later the recommendation is that you use ExternalInterface.

0
Lars Blåsjö On

Generally, I would recommend using ExternalInterface over fscommand. I regard fscommand more or less as deprecated.

That said, what you mention about fscommand being non-blocking could be correct, since ExternalInterface.call() is synchronous, to be able to return a value from the called external function. I guess there could be situations, edge cases, where that could speak in favor of fscommand, but you would probably have to test that.

Again, I would recommend ExternalInterface, it has many features fscommand doesn't have, like preserving data types and automatic serialization/deserialization of objects between ActionScript and the typical external environment - JavaScript in a web page - whereas fscommand only sends strings. Using ExternalInterface in a .NET app, you may have to parse the XML-RPC (that is used internally by ExternalInterface) your self, I believe, but I'm not sure.