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?