How to expose the JavaScript interface for an embedded Flash object?
JavaScript and the Flash Player can exchange data via Flash's ExternalInterface mechanism: you register ActionScript functions that you would like to be able to be called from JavaScript.
My question: How can I figure o开发者_运维知识库ut what ActionScript functions of a Flash object are available for me to call from JavaScript (assuming they are not documented)?
Is there a programatic way to do this in JavaScript?
Thanks!
you can't enumerate them directly (they won't be listed in a for..in loop), but you can test for each one explicitly...
var swf = document.getElementById('theID');
alert('someMethod' in swf); // will alert true if 'someMethod' is exposed via ExternalInterface.addCallback
this might fail if called during $(document).ready or window.onload - the swiff must be 'initialized' (loaded and registered) for the exposed methods to be available at all.
精彩评论