如何以通知SWF完成HTML容器,使用SWFObject容器、通知、HTML、SWF

2023-09-08 12:00:42 作者:守住⒈份执着°

我嵌入Flash对象(SWF文件)到HTML页面。对象是写在AS3和使用Flash Builder构建。它的目的是展示一些动画,然后完成。

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.

这是非常重要的,我能够通知动画已经完成了集装箱,但我无法找到任何工作。我使用 SWFObject的2.2版本。

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.

在Chrome 40和IE 11都试过。

Tried both on Chrome 40 and 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(样品):

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

我的flashFinished功能被永远不会被调用。任何人都可以建议我在做什么错了?谢谢!

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

推荐答案

要避免Flash播放器阻止本地的SWF访问到外部URL(互联网,...)或者与JavaScript或其他行动,沟通火通常一个安全沙箱冲突错误,你要它(SWF)加入到这样的受信任位置的列表:

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 :

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

右键点击您的SWF在浏览器中打开,然后点击全局设置... :

这将打开此页面。

然后点击全局安全设置面板链接右边,它会给你这个页面: Then click on the Global Security Settings panel link at the right side, which will give you 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 :

您刚才输入您的SWF的位置,或它的父目录,或者干脆整个分区喜欢我的形象一样。尽量避免浏览...按钮,有时不工作(至少对我来说)。 确认和关闭该页面,并刷新你的SWF。

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播放器: 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 :

然后到 高级 标签,然后点击 受信任位置设置... 键:

然后,你必须使用添加的SWF的位置 添加... 按钮> 添加文件... 或 添加文件夹... 按钮> 选择您的文件/目录或分区和preSS 确定 , 确认 并关闭所有对话框。 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.

 
精彩推荐
图片推荐