Using the External API for Flash–JavaScript Communication
Using the External API for Flash–JavaScript Communication
Getting the functionality you want out of your Flash application often requires communicating with code outside of Flash Player, such as JavaScript in an HTML page. In cases like this, you need to get ActionScript to invoke JavaScript, or vice versa, in order to enable communication.
In Flash Player 7 and earlier, ActionScript-to-JavaScript communication relied on getURL()
or fscommand()
, while JavaScript was able to communicate with ActionScript by using SetVariable()
, callFrame()
, and callLabel()
.
The ExternalInterface class introduced in Flash Player 8—more generally known as the External API (application programming interface)—enables straightforward communication between Flash and external programs. This article explains the ExternalInterface class in detail.
Requirements
To complete this tutorial you will need to install the following software and files:
Flash Professional 8
Sample files:
Prerequisite Knowledge
Familiarity with JavaScript and the Document Object Model (DOM).
Comments