Javascript 如何使用setTimeout()启动Flash动画?

Javascript 如何使用setTimeout()启动Flash动画?,javascript,settimeout,Javascript,Settimeout,我拼命想让这部flash动画在5秒后播放,但我所做的一切似乎都无法让它正常工作 这是我正在使用的代码: function waitFiveSec() { window.setTimeout(startPlaying,5000); } function startPlaying() { window.document.getElementById("FlashID") } 然后调用HTML文档上的waitFiveSec函数: <body onload="waitFiveS

我拼命想让这部flash动画在5秒后播放,但我所做的一切似乎都无法让它正常工作

这是我正在使用的代码:

function waitFiveSec() {
    window.setTimeout(startPlaying,5000);
}

function startPlaying() {
    window.document.getElementById("FlashID")
}
然后调用HTML文档上的waitFiveSec函数:

<body onload="waitFiveSec()">
这是一个类项目,我必须做基于时间轴的事件,所以我以前从未真正使用过JavaScript

有人能帮我吗

HTML闪存代码:

<div id="animation">
  <p>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="365" height="295" id="FlashID" title="Tractor Animation">
      <param name="movie" value="../Multimedia elements/Animations/Tractor Animation Opt 2.swf" />
      <param name="quality" value="high" />
      <param name="wmode" value="opaque" />
      <param name="swfversion" value="7.0.70.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" />
      <param name="autoplay" value="false" />
      <param name="PLAY" value="false" />
      <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="../Multimedia elements/Animations/Tractor Animation Opt 2.swf" width="365" height="295">
        <!--<![endif]-->
        <param name="quality" value="high" />
        <param name="wmode" value="opaque" />
        <param name="swfversion" value="7.0.70.0" />
        <param name="expressinstall" value="Scripts/expressInstall.swf" />
        <param name="autoplay" value="false" />
        <param name="PLAY" value="false" />
        <!-- 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" /></a></p>
        </div>
        <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>
  </p>
  <p>&nbsp;</p>
</div>
</div>
似乎没什么不对


仅确保在从html调用之前加载文件。

window.document无效。这只是文件。使用控制台调试代码,您将看到一个错误。为什么使用getElementById获取对它的引用会使它开始播放。@elclars当然是window.document有效的。文档从第1天起一直是window的属性。事实上,在JavaScript中,每个全局变量都是window的属性。Katie,请在页面中包含flash对象的HTML代码。@Tomalak:lol。我的错。我习惯于只看文档,以至于忘了那个。