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!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…