關於 Fscommand 和 javascript 的配合
在網頁裏面,flash播放器是可以和瀏覽器通訊的。你可以在flash 裏面用 Fscommand() 發送參數給瀏覽器,
然後在瀏覽器裏面用 Movie1_DoFscommand() 獲得參數。movie1是你在html裏面給這個swf文件的ID名。
·新建一個flash,插入一個按鈕
在按鈕上添加AS
on (release) { fscommand("press"); } |
· 作用爲當鼠標按下這個按鈕時,發出一個名字叫"press"的FS Command
· 然後把它插進網頁中,給它起一個ID的名字,如"jimsons";
· 然後在<head></head>中加進如下的代碼:
<SCRIPT LANGUAGE="javascript">
function jimsons_DOFSCommand(command,args)
//上面的一般是調用FS Command所需要的格式,其中"jimsons"就是給插入網頁中的FLASH動畫的ID名字
{
if (command=="press")
//當fs command="press"時(按鈕被按下時發出這個FS Command)
alert("呵呵,不要碰我啦!");
//彈出警告菜單,這是屬於javascript裏的語句
}
</SCRIPT>
<SCRIPT LANGUAGE="VBScript">
Sub jimsons_FSCommand(ByVal command, ByVal args)
call jimsons_DoFSCommand(command, args)
end sub
</SCRIPT>
//運用VBScript,當FLASH發出FS Command時,執行flash1_DoFSCommand(command, args);
//flash1爲FLASH動畫的id ,這也是運用FS Command時一般所需要的格式
· 將flash插入到網頁中,將其ID號命名爲jimsons如下
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" name="jimsons" width="300" height="300" id="jimsons"> <param name="movie" value="jimsons.swf"> <param name="quality" value="high"> <embed src="jimsons.swf" width="300" height="300" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer";; type="application/x-shockwave-flash" name="jimsons"></embed></object> |