I’m about to write a spec for a Flash developer to build a player control that works similar to the HTML5 <audio> tag.
One of the key points is how to add callbacks, for example, with the audio tag you would do something like:
getElementById('flashAudioPlayer').addEventListener('timeupdate', function() {
// Do stuff
});
Is it possible to have the Flash control support this type of callback passing? Instead of static ‘ExternalInterface’ calls, it would rather call the passed in function object, like in the above example.
Thanks!
Maybe this is doable using JS eval from the Actionscript side, but I think there’s an alernative.
Have your swf call a JS proxy that then broadcasts the message to the registered listeners.
Something along these lines:
JS
AS
This could simplified if you hardcoded more stuff, but perhaps this approach is not that complicated to implement and gives you some flexibility, and makes registering to listener easy for JS “clients” (the more involved part would be in ProxyDispatcher itself).
Hope this makes sense!