Search code examples
flashactionscriptexternalinterfacefscommand

ActionScript: fscommand vs ExternalInterface


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?)


Solution

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