Peut-être que c'est faisable en utilisant JS eval du côté Actionscript, mais je pense qu'il y a un alernatif. Faites en sorte que votre swf appelle un proxy JS qui diffuse ensuite le message aux écouteurs enregistrés.
Quelque chose le long de ces lignes:
JS
var proxyDispatcher = new ProxyDispatcher();
var app = getYourSwf("myswf");
// tell your app to call the dispatch method in the proxyDispatcher object everytime theres a timeupdate
// dispatch will receive the name of the event back, plus the "payload" data (that's up to you to define)
app.registerCallback('proxyDispatcher.dispatch','timeupdate');
// now, add "clients" here
// the idea is that proxyDispatcher registers JS functions to be called when its dispatch method is called
// so, when dispatch is called with 'timeupdate' as the event type, call all listeners for 'timeupdate'...
proxyDispatcher.addEventListener('timeupdate',function() {
});
AS
var _map:Object = {};
private function handleRegisterCallback(jsCallback:String,eventName:String):void {
_map[eventName] = jsCallback;
}
// when there's a timeupdate, check if you have a registered listener for it; if so, call it
private function dispatchTimeupdate():void {
if(_map['timeupdate']) {
// call the registered function, pass the event name and any data you need
ExternalInterface.call(_map['timeupdate'],'timeupdate','your data here');
}
}
Cela pourrait simplifiée si vous Hardcoded plus de choses, mais peut-être cette approche est pas si compliqué à mettre en œuvre et donne vous avez une certaine flexibilité, et rend l'enregistrement à l'auditeur facile pour les "clients" de JS (la partie la plus impliquée serait dans ProxyDispatcher lui-même).
Espérons que cela a du sens!