当前位置:学院首页 >> 美工设计 >> FLASH教程 >> Flash调用Javascript

FLASH教程

Flash调用Javascript

发布于 2008-09-09   次阅读 字体:

标签:Flash调用Javascript   

这里用了两种方法,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=”js.swf” />
<param name=”quality” value=”high” />
<embed src=”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>

网站地图