日期:2014-05-16  浏览次数:20444 次

javascript不能控制flash播放
HTML code
<html>   
<head>   
</head>   
<script>   
  
</script>   
<body>   
<form>   
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0 " width="500" height="400" id="flv">   
    <param name="movie" value="Flvplayer.swf " />   
    <param name="quality" value="high" />   
    <param name="allowFullScreen" value="true" />   
    <param name="enablejs" value="true"/>;//   
    <param name="FlashVars" value="vcastr_file=h.flv&LogoText=www.cnzz.cc&BufferTime=3" />   
    <embed src="Flvplayer.swf " allowfullscreen="true" flashvars="vcastr_file=h.flv&LogoText=www.cnzz.cc" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer " type="application/x-shockwave-flash" width="500" height="400"></embed>   
</object>   
  
<a href="#" onclick="javascript:document.flv.Play()"><font color="#800080">播放</font></a>   
<a href="#" onclick="javascript:document.flv.Stop()"><font color="#800080">停止</font></a>   
</form>   
</body>  



------解决方案--------------------
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" name="mFlash" width="556" height="100" id="mFlash">
<param name="movie" value="ad.swf" />
<param name="quality" value="high" />
<embed src="ad.swf" width="556" height="100" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="mFlash"></embed>
</object>

<br>
播放控制:
<input type="button" value="播放" id="toPlay" onclick="movie.play();this.style.display='none';ss.style.display='block';" style="font:small-caps 900 60px 宋体;" />
<input type="button" value="暂停" id="toStop" onclick="movie.stop();this.style.display='none';pp.style.display='block';" style="font:small-caps 900 60px 宋体;">

<script language="javascript">//获取FLASH
var movie=document.getElementById('mFlash');
var pp=document.getElementById('toPlay');
var ss=document.getElementById('toStop');

//以下是设置按钮大小的,你把数字改成你想要的。
pp.style.height="100px"; //播放按钮高
pp.style.width="130px"; //播放按钮宽

ss.style.height="100px"; //暂停按钮高
ss.style.width="130px"; //暂停按钮宽

pp.style.display="none";
ss.style.display="block";
</script>