How to expose the JavaScript interface for an embedded Flash object?

纵饮孤独 提交于 2019-12-12 18:13:46

问题


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 out 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!


回答1:


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.



来源:https://stackoverflow.com/questions/4343687/how-to-expose-the-javascript-interface-for-an-embedded-flash-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!