To call the JavaScript function from Flash, use the ExternalInterface.call function in ActionScript:
import flash.external.ExternalInterface; // Call a JavaScript function ExternalInterface.call("your_javascript_function"); // Get a return value from a JavaScript function var x:int = ExternalInterface.call("get_x"); // Pass an argument to a JavaScript function var retval:int = ExternalInterface.call("some_js_function", "the-argument");
To call the ActionScript function from JavaScript, first use the ExternalInterface.addCallback function in ActionScript:
// "methodName" is the method to call in JavaScript // instanceObject.realMethod is the method that will be triggered var successful = ExternalInterface.addCallback("methodName", instanceObject, realMethod);
Then take the SWFObject handle in JavaScript and call the ActionScript method as follows:
function makeActionScriptCall() { var flash = document.getElementById(movieName); flash.methodName(parametersIfAny); }
For more information see
source share