从javascript调用flash点击事件

invoke flash click event from javascript

本文关键字:事件 flash javascript 调用      更新时间:2023-09-26

我的html文件中有一个flash对象

<embed id="ZeroClipboardMovie_1" src="/assets/811871e8/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="100" height="38" name="ZeroClipboardMovie_1" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=1&amp;width=100&amp;height=38" wmode="transparent">

例如,当一个html button被点击时,我如何在这个对象上创建点击事件?

您可以通过使用ExternalInterface类并添加回调,从javascript公开(调用)您的flash函数。

AS3(闪存)代码:

ExternalInterface.addCallback('nameForJStoCall',flashFunctionName);

JS代码:

document.getElementById('ZeroClipboardMovie_1').nameForJStoCall(yourParametersIfNeeded);

有关更详细的示例:http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html

但是,您不能

告诉flash从外部发送真正的点击事件(出于安全原因)。调用全屏模式或FileReference框之类的东西将不起作用,除非在flash中实际单击了一个元素。