我正在AS3中创建一个混音器。我有几个声音样本,用户可以选择创建自己的轨道。调音台将“混音”最多4个音轨,并根据需要播放“混合”音轨。我无法让声音同步播放。我很想在闪光灯中处理声音并想知道我错过了什么......这是目前的“混音”功能:
function mixIt(e:MouseEvent) {
if (isPlaying) {
channel1.stop();
}
var mChannel1:SoundChannel = new SoundChannel;
var mChannel2:SoundChannel = new SoundChannel;
var tUrl1:URLRequest = new URLRequest(trackChoice1);
var tUrl2:URLRequest = new URLRequest(trackChoice2);
var s1:Sound = new Sound();
var s2:Sound = new Sound();
var s1Done:Boolean = false;
var s2Done:Boolean = false;
s1.addEventListener(Event.COMPLETE, onSoundLoaded1);
s2.addEventListener(Event.COMPLETE, onSoundLoaded2);
s1.load(tUrl1);
s2.load(tUrl2);
function onSoundLoaded1(e:Event) {
s1Done = true;
if (s2Done) {
playMix()
}
}
function onSoundLoaded2(e:Event) {
s2Done = true;
if (s1Done) {
trace("s2 Done")
playMix()
}
}
function playMix(){
mChannel1 = s1.play(0, 2);
mChannel2 = s2.play(0, 2);
//trace("MIXING TRACKS :" + tUrl1 + " + " + tUrl2);
}
}