In my last post I showed how to communicate from Javascript to ActionScript. To do so I used ExternalInterface in my ActionScript. ExternalInterface allows traffic to flows both ways.
We’ll start in ActionScript this time. Ensure you have imported the ExternalInterface class.
import flash.external.ExternalInterface;
Then create a call to Javascript using the ‘call’ method of the ExternalInterface class.
ExternalInterface.call("sayHello");
You’ll in all likelihood be placing that inside an event like a button click.
In your HTML document now add a Javascript function using the same name in the ActionScript call ie:
function sayHello(){ // do something }