我有几个正弦的音频轨道。我想从一开始就打开一个“TitleMusic”,并允许用户打开和关闭其他轨道。我的代码就目前而言,“TitleMusic”从一开始就播放,所有其他曲目也在播放。我需要切换“track8”和所有其他轨道(未显示),以便它们在开始时关闭。这花了我很长时间才达到这一点,我只需要一些帮助来扭转它。谢谢
import flash.media.Sound;
import flash.media.SoundChannel;
var soundOn:Boolean = true;//This music is ON when we start
var myMusic:TitleMusic = new TitleMusic();
var myChannel1:SoundChannel = myMusic.play(0,1000);//endless loop, in effect
var soundOn3:Boolean = true; //music is ON when we start
var myMusic3:track8 = new track8();
var myChannel3:SoundChannel = myMusic3.play(0,1000); // endless loop, in effect
var myTransform3:SoundTransform;
mySoundButton3.addEventListener(MouseEvent.CLICK,toggleSound3);
mySoundButton3.buttonMode = true;
mySoundButton3.mouseChildren = false;
function toggleSound3(e:MouseEvent)
{
if(soundOn3)
{
// turn sound off
myTransform3 = new SoundTransform();
myTransform3.volume = 0; // silent
myChannel3.soundTransform = myTransform3;
soundOn3 = false;
mySoundButton3.myButtonText.text = "click to turn sound ON";
}
else // sound is off
{
// turn sound on
myTransform3 = new SoundTransform();
myTransform3.volume = 1; // full volume
myChannel3.soundTransform = myTransform3;
soundOn3 = true;
mySoundButton3.myButtonText.text = "click to turn sound OFF";
}
}