ActionScript 3 calls javascript function

Is it possible to call javascript functions inside flash (as3)? How about not in the same domain? Can you provide an approximate fragment for the samedomain and not one domain?

thank!

+3
source share
1 answer

Using ExternalInterface, you can communicate with JavaScript from Flash, but only in the window in which the Flash application is running.

It is just as simple:

ExternalInterface.call("jsFunctionName", argument, argument, ...);

To do the opposite (calling Flash from JavaScript), you do the following:

ExternalInterface.addCallback("jsFunctionName", callbackFunction);

function callbackFunction(arg:String):void {
    trace(arg);
}

And then you can call jsFunctionName("foo")from JavaScript.

For more information, see adobe docs .

As for your cross-domain, you cannot, as far as I know, but you can proxy the call through your server.

+4

Source: https://habr.com/ru/post/1785213/


All Articles