轉載:http://www.iamued.com/qianduan/611.html
翻譯自:http://www.permadi.com/tutorial/flashjscommand/index.html
重點在於 object的id屬性 和 EMBED 的name屬性 swliveconnect=”true” 屬性
| 0102030405060708091011121314151617 |
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="150" HEIGHT="75" id="simplemovie" ALIGN=""> <PARAM NAME=movie VALUE="simplemovie.swf"> <PARAM NAME=quality VALUE=medium> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="simplemovie.swf" quality=medium swliveconnect="true" bgcolor=#FFFFFF WIDTH="150" HEIGHT="75" name="simplemovie" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"> </EMBED></OBJECT> |
通過js擷取flash對象的方法相容表如下
通過得到JavaScript方法來擷取flash對象 相容多瀏覽器
| 01020304050607080910111213141516 |
function getFlashMovieObject(movieName){ if (window.document[movieName]) { return window.document[movieName]; } if (navigator.appName.indexOf("Microsoft Internet")==-1) { if (document.embeds && document.embeds[movieName]) return document.embeds[movieName]; } else // if (navigator.appName.indexOf("Microsoft Internet")!=-1) { return document.getElementById(movieName); }} |
擷取到flash對象可以利用相關方法進行操作
播放:: Play()
停止: StopPlay()
停止並回到首幀: Rewind()
下一幀: TGetProperty(nameOfTargetMovieClip, propertyIndex) and GotoFrame(frameNum)
方大或縮小: Zoom(relative percentage)
發送資料: SetVariable(variableName, variableValue)
讀取資料: GetVariable(variableName)
查看Demo