Flash與JavaScript資訊互動

來源:互聯網
上載者:User

網上提供的這方面資料太少了,研究一兩天,做了個例子,大家可以參考!

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Flash與3D資訊互動</title>
<style type="text/css">
<!--
td {
font-family: "宋體";
font-size: 12px;
}
-->
</style>
</head>
<body onLoad="Init();">
<p>
<!--定義TerraExplorer的資訊視窗對象-->
<object ID="TEInformationWindow" classid="CLSID:3a4f9193-65a8-11d5-85c1-0001023952c1" width="300" height="400"></object>
<!--定義一個TerraExplorer 3D視窗對象-->
<object ID="TE3DWindow" classid="CLSID:3a4f9192-65a8-11d5-85c1-0001023952c1" width=650 height="400"></object>
<!--定義TerraExplorer對象-->
<object ID="TE" CLASSId="CLSID:3a4f9191-65a8-11d5-85c1-0001023952c1"></object>
</p>

<table width="937" border="1" align="left">
<tr>
<td width="369" align="center">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="300" height="150" id="Flash1" align="center">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="f2.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="f2.swf" quality="high" bgcolor="#ffffff" width="300" height="150" name="Flash1" swLiveConnect="true" align="center" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</td>
<!-- -->
<td width="282" align="center">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="300" height="150" id="myFlash" align="center">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="f4.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ccffff" />
<embed src="f4.swf" quality="high" bgcolor="#ccffff" width="300" height="150" name="myFlash" swLiveConnect="true" align="center" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</td>
<td width="264" colspan="2" align="left">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" id="btn1" width="100" height="50" align="center">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="btn1.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="btn1.swf" quality="high" bgcolor="#ffffff" width="100" height="50" swLiveConnect=true id="btn1" name="btn1" align="center" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</td>
</tr>
<tr>
<td width="369" height="200" align="center">
</td></tr>
</table>
</html>
<script language="JavaScript">

var ITerraExplorer = null;
var IPlane = null;
var IMenu = null;
var IObjectManager = null;
var IRender=null;
var ZoomMode = 0;
var zoom_array = new Array();
//瀏覽器設定
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

//初始化
function Init()
{
var temp;
ITerraExplorer = TE.interface("ITerraExplorer5");
IPlane = TE.interface("IPlane5");
IInformationTree = TE.interface("IInformationTree5");
IMenu = TE.interface("IMenu");
IObjectManager = TE.interface("IObjectManager5");
ITerraExplorer.Load("2.fly");
IRender=TE.interface("IRender5");
}
//飛到某個地方--------------------------------------------------------------------------------------------------
// 處理 Flash 影片中的所有 FSCommand 訊息
function myFlash_DoFSCommand(args1,args2)
{
var myFlashObj = InternetExplorer ? myFlash : document.myFlash;
var tX0,tZ0;
tX0 =args1;
tZ0 =args2;
FlyToWhere(tX0,tZ0);
}
// Internet Explorer 的掛鈎
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 &&
navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1)
{
document.write('<SCRIPT LANGUAGE=VBScript\> \n');
document.write('on error resume next \n');
document.write('Sub myFlash_FSCommand(ByVal command, ByVal args)\n');
document.write(' call myFlash_DoFSCommand(command, args)\n');
document.write('end sub\n');
document.write('</SCRIPT\> \n');
}

function FlyToWhere(tX0,tZ0)
{
//建立文字物件
var LabelInfo = new Object();
LabelInfo.Text = "經度 : "+tX0+" 緯度 : "+tZ0;
LabelInfo.Scale = 1;
LabelInfo.BgColor = 236;

IObjectManager.CreateLabel (LabelInfo, tX0, tZ0, 2000.0 );
IPlane.FlyTo (tX0,tZ0,2000.0,117.98,0, -35,"Oval" );
}
//飛到某地------------------------------------------------------------------------------------------------------
function btn1_DoFSCommand(command, args) {
var btn1Obj = InternetExplorer ? document.all.btn1 : document.btn1;
var tX0;
tX0 =args;
klmy();
}
// Internet Explorer 的掛鈎
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1)
{
document.write('<script language=\"VBScript\"\>\n');
document.write('On Error Resume Next\n');
document.write('Sub btn1_FSCommand(ByVal command, ByVal args)\n');
document.write(' Call btn1_DoFSCommand(command, args)\n');
document.write('End Sub\n');
document.write('</script\>\n');
}

function klmy()
{
//建立文字物件
var LabelInfo = new Object();
LabelInfo.Text = "中國 "
LabelInfo.Scale = 1;
LabelInfo.BgColor = 236;

IObjectManager.CreateLabel (LabelInfo, 87, 45, 2000.0 );
IPlane.FlyTo (87,45,2000.0,117.98,0, -35,"Oval" );
}
//-------------------------------------------------------------------------------------------------------------------

</script>

<script language="vbscript">
function TE_OnFrame()
dim x1,y1
IRender.GetMouseInfo 1,x1,y1
ObjType = 0
IRender.ScreenToWorld x1,y1,ObjType,WorldX,WorldHeigth,WorldY,ObjectID
window.document.Flash1.SetVariable "x", WorldX
window.document.Flash1.SetVariable "y", WorldY
end function

</script>
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.