Flash调用Javascript
2008-09-08 19:18:56 来源:WEB开发网这里用了两种方法,getURL(”javascript:函数名”)和ExternalInterface,ExternalInterface更稳定一些。
AS代码:
on (release) {
getURL(”Javascript:say(’我是Flash中的文字,用getURL方法’)”);
}
或
on (release) {
import flash.external.ExternalInterface;
ExternalInterface.call(”say”,”我是Flash中的文字,用ExternalInterface方法”);
}
HTML代码:
<!doctype html public “-//w3c//dtd html 4.0 transitional//en”>
<html>
<head>
<title> new document </title>
<meta name=”generator” content=”editplus”>
<meta name=”author” content=”">
<meta name=”keyWords” content=”">
<meta name=”description” content=”">
<script language=”javascript”>
<!–
function say(word) {
document.getElementById(”word”).innerHTML = word
}
window.onload = function() {
say(’html’)
}
//–>
</script>
</head>
<body>
<object classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″ codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0”
id=”swf”
width=”250″
height=”150″
title=”AsJsCall”
>
<param name=”movie” value=http://www.cncms.com/”js.swf” />
<param name=”quality” value=”high” />
<embed src=http://www.cncms.com/”js.swf” quality=”high” pluginspage=”http://www.macromedia.com/go/getflashplayer” type=”application/x-shockwave-flash” width=”250″ height=”150″></embed>
</object>
Flash say: <span id=”word” style=”color:red”></span>
</body>
</html>
Tags:Flash 调用 Javascript
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接