Quick example on how to call a js function via URLRequest:
var r:URLRequest = new URLRequest("javascript:functionName()"); navigateToURL(r,'_self');
To call an Actionscript 3 function from Javascript:
import flash.external.ExternalInterface; ExternalInterface.addCallback("changeText", changeTheText); // so javascript from html can talk to flash function changeTheText(t:String):void { txtText.text = t; }
Call the AS3 function from Javascript. (first select the Flash object in the DOM)
var flashObj = document.getElementById('flashObject'); <a href="#" onClick="flashObj.changeText('it works!');">Click me!</a>
Use the ExternalInterface class to call a JavaScript function from AS3:
ExternalInterface.call("javascript_function");
Pass an argument to the Javascript function and/or receive a return value from it :
var returnvalue:int = ExternalInterface.call("js_function", "argument_for_js_function","another_argument");
Thanks in advance.
Could I get an example of this? I'm trying to make the mute button work with these calls here: www.friedmanllp.com/home3.php and I'm having some errors. Need to pass a pass a click event (the mute button) to the other flash file and turn off and on the sound.
Thanks in advance.
Advance thanks..... :)