| 订阅 | 在线投稿
分享
 
 
 

Flash调用Javascript

来源:互联网网民  宽屏版  评论
2008-09-09 07:29:15

这里用了两种方法,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>

 
特别声明:以上内容(如有图片或视频亦包括在内)为网络用户发布,本站仅提供信息存储服务。
 
这里用了两种方法,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>
󰈣󰈤
 
 
 
>>返回首页<<
 
 热帖排行
 
 
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
©2005- 王朝网络 版权所有