JavaScript控制flash操作 相容IE FF

來源:互聯網
上載者:User

轉載: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

    相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.