我正在将Flash对象(swf文件)嵌入到HTML页面中。该对象使用as3编写,并使用Flash Builder构建。其目的是显示一些动画,然后完成。如何使用swfobject通知已完成SWF的HTML容器
这是真的对我很重要的是能够以通知动画结束容器,但我无法找到任何工作。我正在使用swfobject version 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” 功能被从来没有所谓。任何人都可以建议我做错了什么?谢谢!
我会去与ExternalInterface调用,你有没有试过一个警报,看看它是否工作? - > ExternalInterface。呼叫(“警报”,“来自Flash的呼叫”); – Shaeldon 2015-02-24 10:59:19
我认为你的代码很好,但是如果你在本地尝试它,你可能会得到一个安全异常,所以在Web服务器上试试它。 – akmozo 2015-02-24 11:19:59
@Shaeldon SecurityError:错误#2060:安全沙箱冲突:ExternalInterface调用者文件:/// C:/...../myflash.swf无法访问file:/// C:/...../page。 HTML。毕竟,akmozo看起来是对的。 – 2015-02-24 18:12:13