Actionscript 3 call a javascript function
is it possible to call javascript functions inside flash (as3)? How about not in 开发者_开发技巧the same domain? Can you provide an example snippet for samedomain and not same domain?
thanks!
Using the ExternalInterface you can communicate with JavaScript from Flash, however only in the window where the Flash application is running.
It is as easy as doing:
ExternalInterface.call("jsFunctionName", argument, argument, ...);
To do the reverse (calling Flash from JavaScript) you do the following first:
ExternalInterface.addCallback("jsFunctionName", callbackFunction);
function callbackFunction(arg:String):void {
trace(arg);
}
And then you can call jsFunctionName("foo")
from JavaScript.
See the adobe docs for more info on that.
As for your cross domain, you can't as far as I know, but you may be able to proxy the call via your server.
精彩评论