开发者

Calling a Namespaced JavaScript Function from Flash

Can I use ExternalInterface to call a namespaced JavaScript function?

//JavaScript
foo.bar = function(baz) {}

开发者_如何学C// AS3
import flash.external.ExternalInterface;
ExternalInterface.call('foo.bar', baz);


The documentation of ExternalInterface.call is a little misleading. it states the first parameter must be a function name, which is not the whole truth. it can be any string that can be evaluated as a proprer JS expression. In fact

ExternalInterface.call(func, param_1, ... , param_n);

is equivalent to

eval(func)(param_1, ... , param_n);

so you may just as well do the following

ExternalInterface.call("function (foo) { alert(foo); return true; }","test");

this technique is sometimes used for Flash JS injection. hope this clarifies things ...


Yes. Yes you can.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜