您所在的位置:小祥子 » 软件教程 » Flash » 正文

Flash调用JS

时间:2015-01-27 编辑:佚名 来源:互联网

标签: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>

关键词:Flash JS