Reputation: 5819
I understand that ExternalInterface.call('functionName', arguments);
in ActionScript 3 can be used to communicate with Javascript function functionName(arguments)
defined on the HTML page.
But what about a custom object instance? Say that I have:
(function (factory, $, undefined) {
factory.worker = function () {
...
};
factory.worker.prototype.init = function (params) {
...
};
factory.worker.prototype.flash_tell_me_something = function (params) {
...
};
}(window.factory = window.factory || {}, jQuery));
And in order to use it, I combine it with jQuery to create an instance, plus the Flash object:
$(document).ready(function () {
var myworker = new factory.worker();
myworker.init();
var myloadedcallback = function () {
};
flashVars = {loadedCallback: myloadedcallback};
...
swfobject.embedSWF(swfUrl, id, 215, 138, version, null, flashVars, params);
});
How do I call myworker.flash_tell_me_something(...)
from Flash?
Upvotes: 1
Views: 83
Reputation: 5267
Try this solution:
if(ExternalInterface.available)
{
ExternalInterface.call("window.myworker.flash_tell_me_something", "hello");
}
You can also call worker
directly, rather than window.worker
if they are (worker and flash object) in the same namespace.
Upvotes: 1