Calling Javascript functions from Flash is very easy. We use a class called ExternalInterface. Here is ActionScript code:
import flash.external.*;
import flash.events.Event;
button1.addEventListener(MouseEvent.CLICK, buttonHandle);
function buttonHandle(event:MouseEvent)
{
ExternalInterface.call("showMessage");
}
Here flash.external is a package where the class ExternalInterface is found.
The code is very simple. Event listener to button is added. And call is a method of ExternalInterface class, the parameter passed to call() is a name of the Javascript function.
The Javascript function is an alert message:
function showMessage()
{
alert("Hi from flash");
}


