我有一个可以打开和关闭音乐的按钮。当我关闭它时,它可以工作,但当我尝试再次播放音乐时,它不工作!请帮帮忙
var sound=true;
var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
mySound.load(new URLRequest("Track.mp3"));
myChannel = mySound.play();
function changeSound(event:MouseEvent):void {
if(sound==true){
myChannel.stop();
sound=false;
}
if(sound==false){
myChannel.reset();
sound=true;
}
}发布于 2015-06-07 20:36:19
SoundChannel没有reset方法。调用play而不是reset。
if(sound==false){
myChannel = mySound.play();
sound=true;
}另外,您应该将else放在两个if之间。
if(sound==true){
myChannel.stop();
sound=false;
}
else if(sound==false){
myChannel = mySound.play();
sound=true;
}https://stackoverflow.com/questions/30693337
复制相似问题