代码
flash 方法:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>call flash function </title>
<script language=javascript>
function test()
{
var str = document.getElementById('main').back(); alert(str);
}
</script>
</head> <body>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="main" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="main.swf" />
<param name="wmode" value="transparent">
<param name="quality" value="high" />
<param name="bgcolor" value="ffffff" />
<param name="allowScriptAccess" value="always" />
<embed src="test.swf" quality="high" bgcolor="ffffff" width="217" height="24" name="upload" align="middle" play="true" wmode="transparent" loop="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object>
</body>
</html>
flash 方法:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import flash.external.ExternalInterface;
public function initApp():void {
ExternalInterface.addCallback("back",back);
ExternalInterface.call("test");
}
public function back():String {
return "back";
}
]]>
</mx:Script>
</mx:Application>