我正在将 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”函数从未被调用。谁能建议我做错了什么?谢谢!