Home / Articles / Adobe Flash / External Communications with Flash 8: How to Use the ExternalInterface

External Communications with Flash 8: How to Use the ExternalInterface

Article Description

Kris Hadlock explores the use of the ExternalInterface class in Flash 8. With ExternalInterface, you can build robust object-oriented Flash applications that can be connected to the outside world and tied to databases and other server-side processes.

Like this article? We recommend

Macromedia Flash 8: Training from the Source

Macromedia Flash 8: Training from the Source

$44.99

Handling Unsupported Browsers

What happens if the user’s browser doesn’t support the ExternalInterface class? Flash offers an available property with a Boolean value that can be used to check whether the class is available before you execute the code. This is also a good time to display a message, if the users’ browser doesn’t support the class. The following code is used in the sample to handle these situations:

if(ExternalInterface.available)
{
 this.message._visible = false;
 ExternalInterface.addCallback("highlightItem", this, highlightItem);
 ExternalInterface.addCallback("addAllItems", this, addAllItems);
 ExternalInterface.call("onFlashLoaded");
}

This code checks for the availability of the class; if it’s not supported, the code is never executed, and the message that displays the requirements is left visible to inform the user of the issue.