如何使用 swfobject 通知 HTML 容器 SWF 已完成 [英] How to notify the HTML container that the SWF has finished, using swfobject

查看:27
本文介绍了如何使用 swfobject 通知 HTML 容器 SWF 已完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

能够通知容器动画已经完成对我来说真的很重要,但我找不到任何有效的东西.我使用的是 .

  • 然后,正如图片中提到的,点击编辑位置...组合框和添加位置,这会给你这个框:

您只需输入您的 swf 位置,或者它的父目录,或者像我在图像中所做的那样简单地输入整个分区.尽量避免浏览..."按钮,有时它不起作用(至少对我而言).确认并关闭页面并刷新您的 swf.

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

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

  • 然后转到高级标签并点击可信位置设置...按钮:

  • 然后您必须使用添加..按钮> 添加文件...添加文件夹... 按钮 > 选择您的文件/目录或分区,然后按 OK确认并关闭所有对话框.

然后您只需刷新页面即可.

I am embedding a flash object (swf file) into an HTML page. The object is written in as3 and built using Flash Builder. Its purpose is to show some animation, then finish.

It is really important to me to be able to notify the container that the animation has finished, but I can't find anything that works. I am using swfobject version 2.2.

Tried both on Chrome 40 and IE 11.

HTML (sample):

<!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 (sample):

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');
        }
    }
}

My "flashFinished" function gets never called. Can anyone suggest what am I doing wrong? Thanks!

解决方案

To avoid that Flash player blocks your local swf to access to an external URL (internet, ...) or to communicate with javascript or some other actions that fire usually a security sandbox violation error, you have to add it (the swf) to the list of trusted locations like this :

For Flash Player PPAPI (like Opera and Chrome) :

  • Right click on your swf opened in the browser, then Global Settings... :

Which will open this page.

  • Then, as it's mentioned in the image, click on Edit locations... combo box, and Add location, which will give you this box :

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.

For Flash Player ActiveX (like IE) and NPAPI (like Firefox) :

  • Right click on your swf opened in the browser, then Global Settings..., you can also go to your system control panel and open Flash Player :

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

  • 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.

Then you have just to refresh your page.

这篇关于如何使用 swfobject 通知 HTML 容器 SWF 已完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆