Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 517

Programming actionscript 3.0
Table of Contents

Advertisement

Understanding ActionScript to ActiveX container
communication
Communication using the External API with an ActiveX container application works like
communication with a web browser, with one important difference. As described earlier,
when ActionScript communicates with a web browser, as far as the developer is concerned, the
functions are called directly; the details of how the function calls and responses are formatted
to pass them between the player and browser are hidden. However, when the External API is
used to communicate with an ActiveX container application, Flash Player sends messages
(function calls and return values) to the application in a specific XML format, and it expects
function calls and return values from the container application to use the same XML format.
The developer of the ActiveX container application must write code that understands and can
create function calls and responses in the appropriate format.
The Introvert IM C# example includes a set of classes that allow you to avoid formatting
messages; instead, you can work with standard data types when calling ActionScript functions
and receiving function calls from ActionScript. The ExternalInterfaceProxy class, together
with other helper classes, provides this functionality, and can be reused in any .NET project to
facilitate External API communication.
The following sections of code, excerpted from the main application form (AppForm.cs),
demonstrate the simplified interaction that is achieved by using the ExternalInterfaceProxy
class:
public class AppForm : System.Windows.Forms.Form
{
...
private ExternalInterfaceProxy proxy;
...
public AppForm()
{
...
// Register this app to receive notification when the proxy receives
// a call from ActionScript.
proxy = new ExternalInterfaceProxy(IntrovertIMApp);
proxy.ExternalInterfaceCall += new
ExternalInterfaceCallEventHandler(proxy_ExternalInterfaceCall);
...
}
...
Example: Using the External API with an ActiveX container
517

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents