开发者

Can I call anonymous function from ExternalInterface.call() method?

开发者 https://www.devze.com 2023-01-23 08:40 出处:网络
I need to get a javascript var in my Flash application. I like to be able to just set a variable in the javascript (client constraints) rather than defin开发者_如何学Pythone a function.

I need to get a javascript var in my Flash application. I like to be able to just set a variable in the javascript (client constraints) rather than defin开发者_如何学Pythone a function.

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

AS:

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

JS:

var someVar = "Test";

This does not work and I suspect it is because the ExternalInterface.call() does not like the anonymous function. Is there a way to do this?

Thanks


oops. Forgot the ';'

It works. Thanks anyways all.

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


Shouldn't it still work without the ; ?

You also don't need to pass null by the way. But I think a better way to do it is

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

Note the () make its get called.

I don't have Flash right now to test it though. Let me know if it doesn't work

0

精彩评论

暂无评论...
验证码 换一张
取 消