如何使用 swfobject 通知 HTML 容器 SWF 已完成

2023-12-12

我正在将 flash 对象(swf 文件)嵌入到 HTML 页面中。该对象是用 as3 编写的,并使用 Flash Builder 构建。它的目的是显示一些动画,然后完成。

能够通知容器动画已完成对我来说非常重要,但我找不到任何有效的方法。我在用swfobject 版本 2.2.

在 Chrome 40 和 IE 11 上都尝试过。

HTML(示例):

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
    <script type="text/javascript" src="js/swfobject.js"></script>
    <script type="text/javascript">
        function flashFinished() {alert('finished!');}
    </script>
    <script type="text/javascript">
        var flashVars = {}
        var flashParams = {allowscriptaccess : 'sameDomain'}
        var flashAttributes = {id : 'myflash', name : 'myflash'}
        swfobject.embedSWF('myflash.swf', 'flashObject', '960', '720', '9.0.0', 'swf/expressInstall.swf',
                flashVars, flashParams, flashAttributes);
    </script>
</head>
<body>
    <div id="flashObject">
        <p>To view this page please make sure that an updated version of Adobe Flash Player is installed.</p>
    </div>
</body>

AS3(示例):

package
{
    public class myflash extends Sprite
    {
        public function myflash()
        {
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            startPlay();
        }
        private function startPlay() : void {
            // do whatever, then make sure function finishPlay is called in the end
        }
        private function finishPlay(event:TimerEvent) : void {
            if (ExternalInterface.available)
                ExternalInterface.call('flashFinished');
        }
    }
}

我的“flashFinished”函数从未被调用。谁能建议我做错了什么?谢谢!


为了避免 Flash 播放器阻止您的本地 swf 访问外部 URL(互联网等)或与 javascript 或其他一些通常会引发安全沙箱违规错误的操作进行通信,您必须将其(swf)添加到像这样的受信任位置列表:

对于 Flash Player PPAPI(如 Opera 和 Chrome):

  • 右键单击在浏览器中打开的 swf,然后全局设置... :

enter image description here

哪个会打开这一页.

  • 然后单击全局安全设置面板右侧的链接,将为您提供此页面:

enter image description here

  • 然后,如图所示,单击编辑地点...组合框,以及添加位置,这会给你这个框:

enter image description here

You have just to type your swf location, or it's parent directory, or simply the whole partition like what I did in the image. Try to avoid "Browse ..." buttons, sometimes it doesn't work (at least for me). Confirm and close the page and refresh that of your swf.

对于 Flash Player ActiveX(如 IE)和 NPAPI(如 Firefox):

  • 右键单击在浏览器中打开的 swf,然后全局设置...,您还可以转到系统控制面板并打开Flash播放器 :

enter image description here

  • Then go to Advanced tab and click Trusted Location Settings... button :

enter image description here

  • Then you have to add the swf location using Add.. button > Add File... or Add folder... button > select your file/dir or partition and press OK, Confirm and close all dialogs.

enter image description here

然后你只需刷新页面即可。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 swfobject 通知 HTML 容器 SWF 已完成 的相关文章