当前位置:软件学习 > Flash >>

js改变flash中播放的音乐

js改变flash中播放的音乐

var musicName:String;
var mysound:Sound = new Sound();
mysound.loadSound(musicName+".mp3",true);
my_sound.onLoad = function(success:Boolean) {
if(success){
  mysound.start();
}else{
  _root.movie.stop();
  }
}
mysound.onSoundComplete = function() {
  mysound.start();
};
_root.but.onRelease=function(){
  mysound.stop();
}

之后就是将flash插入到网页中了,(PS.因为不知道怎么在AC_FL_RunContent这个JS中插入参数,所以我没有用这个JS)

以下是Html中的代码
<div id="swf">
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="78" height="85">
<param name="movie" value="music.swf?musicName=" />
<param name="quality" value="high" />
<embed src="music.swf?musicName=" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="78" height="85"></embed>
</object>
</div>
<ul id="list">
<li><a href="#" name="sound1" >sound1</a></li>
<li><a href="#" name="sound2" >sound2</a></li>
</ul>

这个是JS的代码
<script type="text/javascript">
var c //Flsah的地址和音乐地址参数
function playSound(whichMusic){
  var myMusic=whichMusic.getAttribute("name") //获取name的值,也就是音乐的地址
  var _script=document.getElementById("swf") //swf容器 Id为swf
  var forFF=_script.getElementsByTagName("param")
  var forIE=_script.getElementsByTagName("embed")
  forFF[0].setAttribute("value",constant+myMusic)
  forIE[0].setAttribute("src",constant+myMusic)
}
</script>

补充:flash教程,As3.0
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,