Is it possible to call an anonymous function from the ExternalInterface.call () method?

I need to get javascript var in my flash application. I like just setting a variable in javascript (client constraints) rather than defining a function.

Can this be done? I am trying to use ExternalInterface.call ()

AS:

ExternalInterface.call("function(){return window.someVar}", null);

JS:

var someVar = "Test";

This does not work, and I suspect that this is because ExternalInterface.call () does not like an anonymous function. Is there any way to do this?

thank

+3
source share
2 answers

oops. Forgot ';'

It works. Thank you anyway.

ExternalInterface.call("function(){return window.someVar;}", null)
+2
source

Should he not work without;

You also do not need to pass null. But I think the best way to do this is

ExternalInterface.call("(function(){return window.someVar}()", null)

, () .

Flash , . , .

+1

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


All Articles