您的位置:首页 > 其它

as3中页面中的flash和页面交互,(ExternalInterface应用)

2008-12-24 09:17 330 查看
flash中的代码:

import flash.external.*;

import flash.event.MouseEvent;

function callWrapper(event:MouseEvent):void {

var s:String;

if (ExternalInterface.available) {

var wrapperFunction:String = "changeDocumentTitle";

s = ExternalInterface.call(wrapperFunction,ti1.text);

} else {

s = "Wrapper not available";

}

trace(s);

}

btn.addEventListener("click",callWrapper);

网页的代码:

<html><head>

<title>as3中页面中的flash和页面交互</title>

</head>

<body scroll=’no’><SCRIPT LANGUAGE=”JavaScript”>

function changeDocumentTitle(a) {

window.document.title=a;

alert(a);

return "successful";

}

</SCRIPT>

<h1>as3中页面中的flash和页面交互</h1>

<table width='100%' height='100%' cellspacing='0' cellpadding='0'>

<tr>

<td valign='top'>

<object id='mySwf' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' height='200' width='400'>

<param name='src' value='ExternalInterface.swf'/>

<param name='flashVars' value=''/>

<embed name='mySwf' src='ExternalInterface.swf' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' height='100%' width='100%' flashVars=''/>

</object>

</td>

</tr>

</table>

</body></html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: