From Enterprise Development with Flex by Yakov Fain, Anatole Tartakovsky, Victor Rasputnis
The ExternalInterface Class
Flex can communicate with JavaScript using an ActionScript class called ExternalInterface. This class allows you to map ActionScript and JavaScript functions and invoke these functions either from ActionScript or from JavaScript. The use of the class ExternalInterface requires coding in both languages.
For example, to allow JavaScript’s function jsIsCalling() to invoke a function asToCall(), you write in ActionScript:
ExternalInterface.addCallback("jsIsCalling", asToCall);
Then, you use the ID of the embedded .swf (e.g., mySwfId set in the HTML object) followed by a JavaScript call like this:
if(navigator.appName.indexOf("Microsoft") != -1){
window["mySwfId"].asToCall();
} else {
document.getElementById("mySwfId").asToCall();
}