一、介绍与Flash动画控制有关的javascript函数:
函数名 使用 作用
play() wgzc.play() 播放Flash动画
stopplay() wgzc.stopplay() 停止播放Flash动画
rewind() wgzc.rewind() 停止播放Flash动画并返回第一帧
totalframes() wgzc.totalframes() 返回Flash动画总帧数
gotoframe(int num) wgzc.gotoframe(int num) 转到指定帧
注:wgzc是flash的id
二、程序代码:
<html> <head> <script language="javascript"> function init() { document.changeframe.totalfrm.value=document.wgzc.totalframes } </script> </head> <body οnlοad="init()" bgcolor="#FFFFFF" bgproperties="fixed"> <fieldset> <legend><font color="#FF0000">控制Flash动画</font></legend> <form name="changeframe"> <font color="#800000"> Flash动画帧数:</font><font color="#000080"><b><input name="totalfrm" type="text" size=4 value="1" disabled> </b></font><font color="#800000"> 输入第</font><b><font color="#000080"><input name="framenum" type="text" size=4 value="1"></font></b><font color="#800000">帧,再点击"指定帧"。</font> </form> <a href="#" οnclick="javascript:document.wgzc.play()"><font color="#800080">播放</font></a> <b><font color="#000080"> </font></b> <a href="#" οnclick="javascript:document.wgzc.stopplay()"><font color="#800080">停止</font></a> <font color="#000080"> <b> </b></font> <a href="#" οnclick="javascript:document.wgzc.rewind()"><font color="#800080">停止返回第一帧</font></a> <b><font color="#000080"> </font></b> <a href="#" οnclick="javascript:document.wgzc.gotoframe(document.changeframe.framenum.value)"><font color="#800080">指定帧</font></a><center> </fieldset> <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" ID=wgzc WIDTH=500 HEIGHT=100> <PARAM NAME=movie VALUE="http://www.jzxue.com/Files/Remoteupfile/2007-4/17/20070416205052_m2.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="http://www.jzxue.com/Files/Remoteupfile/2007-4/17/20070416205052_m2.swf" quality=high bgcolor=#FFFFFF WIDTH=500 HEIGHT=100 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"> </EMBED> </OBJECT> </center> </body> </html> |