<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>js调用flash方法</title>
</head>
<body>
<form name="jsForm">
<object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="400">
<param name="movie" value="JsToAs.swf" />
<param name="quality" value="high" />
<param name="swfversion" value="8.0.35.0" />
<param name="allowScriptAccess" value="always" />
<param name="wmode" value="transparent" />
<embed src="JsToAs.swf" quality="high" wmode="transparent" width="400" height="400" id="FlashID" name="FlashID" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>
</object>
<input type="button" onclick="callExternalInterface()" value="JS调用AS方法" />
</form>
<script>
function callExternalInterface() {
getFlashMovieObject("FlashID").say("Hello,World");
}
//获取flash对象 add by milan 2014.02.27
function getFlashMovieObject(movieName){
if (window.document[movieName]) {
return window.document[movieName];
}
if (navigator.appName.indexOf("Microsoft Internet") == -1) {
if (document.embeds && document.embeds[movieName])
return document.embeds[movieName];
}else {
return document.getElementById(movieName);
}
}
</script>
</body>
</html>