User Guide
514 Using the External API
Detecting the browser type
Because of differences in how browsers access content, it’s important to always use JavaScript
to detect which browser the user is running and to access the movie according to the browser-
specific syntax, using the window or document object, as shown in the
getSWF() JavaScript
function in this example:
<script language="JavaScript">
...
function getSWF(movieName)
{
if (navigator.appName.indexOf("Microsoft") != -1)
{
return window[movieName];
}
else
{
return document[movieName];
}
}
...
</script>
If your script does not detect the user’s browser type, the user might see unexpected behavior
when playing SWF files in an HTML container.
Example: Using the External API with an
ActiveX container
This example demonstrates using the External API to communicate between ActionScript
and a desktop application that uses the ActiveX control. The example reuses the Introvert IM
application, including the ActionScript code and even the same SWF file, and therefore does
not describe the use of the External API in ActionScript. Familiarity with the preceding
example will be helpful in understanding this one.
The desktop application in this example is written in C# using Microsoft Visual Studio .NET.
The focus of the discussion is the specific techniques for working with the External API using
the ActiveX control. This example demonstrates the following:
■ Calling ActionScript functions from a desktop application hosting the Flash Player
ActiveX control
■ Receiving function calls from ActionScript and processing them in an ActiveX container
■ Using a proxy class to hide the details of the serialized XML format that Flash Player uses
for messages sent to an ActiveX container