请问如何用JS控制下边这个Falsh播放器?比如:开始、暂停、停止等……
<object height="300" align="absmiddle" width="185" id="Hjmp3player_1" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">
  <param value="always" name="allowScriptAccess">
  <param value="http://bulo.hjenglish.com/musicbox/players/List_mp3Player2/mp3player.swf" name="movie">
  <param value="high" name="quality">
  <param value="noscale" name="scale">
  <param value="transparent" name="wmode">
  <param value="userid=5109575&amp;listid=11514&amp;autoplay=true&amp;_display=true&amp;_playlist=true&amp;_random=false&amp;hjptype=list&amp;player=3&amp;height=300&amp;width=185" name="FlashVars">
  <embed height="300" align="absmiddle" width="185" flashvars="userid=5109575&amp;listid=11514&amp;autoplay=true&amp;_display=true&amp;_playlist=true&amp;_random=false&amp;hjptype=list&amp;player=3&amp;height=300&amp;width=185" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowscriptaccess="always" name="Hjmp3player_1" bgcolor="#eeeeee" wmode="transparent" scale="noscale" quality="high" src="http://bulo.hjenglish.com/musicbox/players/List_mp3Player2/mp3player.swf">
</object>

解决方案 »

  1.   


    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);
      }
    }
    Example: <a href="#" onclick="getFlashMovieObject('flashId').Play();">Play</a>播放动画:Play()
    停止动画:StopPlay()
    动画是否正在播放:IsPlaying()
    跳转到某帧:GotoFrame(frame_number)
    获取动画总帧数:TotalFrames()
    回传当前动画所在帧数:CurrentFrame()
    使动画返回第一帧:Rewind()
    放大指定区域:SetZoomRect(left,top,right,buttom)
    改变动画大小:Zoom(percent)
    使动画在 x,y 方向上平移:Pan(x_position,y_position,unit)
    返回动画被载入的百分比:PercentLoaded()
    加载动画:LoadMovie(level_number,path)
    movie_clip 跳转到指定帧数:TGotoFrame(movie_clip,frame_number)
    movie_clip 跳转到指定标签:TGotoLabel(movie_clip,label_name)
    回传 movie_clip 当前帧:TCurrentFrame(movie_clip)
    回传 movie_clip 当前标签:TCurrentLabel(movie_clip)
    播放 movie_clip:TPlay(movie_clip)
    停止 movie_clip 的播放:TStopPlay(movie_clip)
    获取变量:GetVariable(variable_name)
    变量赋值:SetVariable(variable_name,value)
    call 指定帧上的 action:TCallFrame(movie_clip,frame_number)
    call 指定标签上的 action:TCallLabel(movie_clip,label)
    获取 movie_clip 的指定属性:TGetProperty(movie_clip,property)
    设置 movie_clip 的指定属性:TSetProperty(movie_clip,property,number)
      

  2.   

    上边的方法试了不管用……<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Example4</title>
    <script type="text/javascript">
    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 {
        return document.getElementById(movieName);
      }
    }</script>
    </head>
     
    <body>
    <object height="300" align="absmiddle" width="185" id="Hjmp3player_1" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">
      <param value="always" name="allowScriptAccess">
      <param value="http://bulo.hjenglish.com/musicbox/players/List_mp3Player2/mp3player.swf" name="movie">
      <param value="high" name="quality">
      <param value="noscale" name="scale">
      <param value="transparent" name="wmode">
      <param value="userid=5109575&amp;listid=11514&amp;autoplay=true&amp;_display=true&amp;_playlist=true&amp;_random=false&amp;hjptype=list&amp;player=3&amp;height=300&amp;width=185" name="FlashVars">
      <embed height="300" align="absmiddle" width="185" flashvars="userid=5109575&amp;listid=11514&amp;autoplay=true&amp;_display=true&amp;_playlist=true&amp;_random=false&amp;hjptype=list&amp;player=3&amp;height=300&amp;width=185" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowscriptaccess="always" name="Hjmp3player_1" bgcolor="#eeeeee" wmode="transparent" scale="noscale" quality="high" src="http://bulo.hjenglish.com/musicbox/players/List_mp3Player2/mp3player.swf">
    </object>
    <button onclick="getFlashMovieObject('Hjmp3player_1').StopPlay()">测试</button>
    </body>
    </html>
    谁来帮我看看,谢谢
      

  3.   

    1.不要随意把我的[]改成.,会找不到对象
    2.基本上你的代码已经对了,只是javascript不能跨域,同样也不能控制跨域的flash,要将flash放到同一个域中
    3.我在我的Blog里加了Example,如果有问题请查看http://www.51tasty.com/example1/example1.html,或留言
      

  4.   

    跟[]没关系,这个“[]”代表关联数组,是数组的一种用发,对象的属性除了用object.xxx可以访问外还可以用关联数组来访问object["xxx"],兄弟搞js多久了?这是js核心内容
      

  5.   


     function F(w, h) {
       this.width = w;
       this.height = h;
     }
     function FS(x, y, w, h) {
       F.call(this, w, h);
       this.x = x;
       this.y = y;
     }
     FS.prototype = new F()
     FS.prototype.constructor = FS;
     delete FS.prototype.width;
     delete FS.prototype.height;
     var r = new FS(1, 2, 3, 4);
     alert(r.x);
     alert(r["y"]);
     alert(r["width"]);
     alert(r.height);
      

  6.   

    楼主这个需要写好接口,js来调用接口,单单js是搞不定的
      

  7.   

    我晕了......window.document[movieName]跟window.document["movieName"]先搞清楚吧.......
    如果你愿意用eval("window.document."+movieName),我当然没有意见......