如何在jquery按钮单击上重播swf电影?

时间:2013-05-01 19:08:09

标签: javascript jquery flash

我有一个网页,上面有几个在Dreamweaver中创建的swf电影,并输出了几个像这样的对象标签:

<object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="160" height="600">
    <param name="movie" value="Banners Template/Example_160x600.swf" />
    <param name="quality" value="high" />
    <param name="wmode" value="opaque" />
    <param name="swfversion" value="9.0.45.0" />
    <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
    <param name="expressinstall" value="Scripts/expressInstall.swf" />
    <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. --> 
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="Banners Template/Example_160x600.swf" width="160" height="600">
      <!--<![endif]-->
      <param name="quality" value="high" />
      <param name="wmode" value="opaque" />
      <param name="swfversion" value="9.0.45.0" />
      <param name="expressinstall" value="Scripts/expressInstall.swf" />
      <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
      <div>
        <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
        <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
      </div>
      <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
  </object>
<script type="text/javascript">
swfobject.registerObject("FlashID");
</script>

我想做以下事情:

  1. Swf动画在页面加载时运行一次(这是 目前正在发生)
  2. 用户点击“重播电影”按钮后, 它与之关联的swf将重播,直到电影结束。
  3. 我一直试图找到一些可以利用javascript或jQuery重新加载对象标签内容或重放swf但没有成功的代码。如何在jquery按钮上重播swf电影?

1 个答案:

答案 0 :(得分:0)

演示: http://jsfiddle.net/tive/Ff7Mq/

演示2: http://jsfiddle.net/tive/J6WQm/

捕获事件并更改文件的来源。 或者使用你的swf对象再次渲染div。

var initVideos = function () {
    var divs = $("ul li a");

    // bind your click event to the divs
    divs.click(function (e) {
        e.preventDefault(); // use this when you're triggering anchor tags
        flashembed("videoArea", $(this).prop("href"));
        divs.removeClass("active");
        $(this).addClass("active");
    });
};