Can I use ExternalInterface to call a namespaced JavaScript function?
//JavaScript
foo.bar = function(baz) {}
// AS3
import flash.external.ExternalInterface;
ExternalInterface.call('foo.bar', baz);
Can I use ExternalInterface to call a namespaced JavaScript function?
//JavaScript
foo.bar = function(baz) {}
// AS3
import flash.external.ExternalInterface;
ExternalInterface.call('foo.bar', baz);
Yes. Yes you can.
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 factis equivalent to
so you may just as well do the following
this technique is sometimes used for Flash JS injection. hope this clarifies things ...