Passing in arguments from js --> as3 via ExternalInterface
Is it possible to use javascript to call a method in as3 and pass in an object argument? This would act as a setter in some sense...
Thanks in advance for any advice!
Is it possible to use javascript to call a method in as3 and pass in an object argument? This would act as a setter in some sense...
Thanks in advance for any advice!
You'd use ExternalInterface.addCallback to register a function call from JS:
// AS
// register call from Javascript
ExternalInterface.addCallback("callFromJS", callFromJS);
// display the message from Javascript
function callFromJS(s:String):void
{
textfield.text = s;
}
Then call from JS:
// JS
flashObject.callFromJS("Hello from JS");
You may need to set allowScriptAccess to true in the HTML embed code.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.