Tengo un problema con un código en AS3, resulta que tengo 4 botones, 3 de ellos reproducen un sonido diferente y el ultimo apaga todo, todo funciona bien solo que al querer oprimir de nuevo un botón, me arroja el siguiente error: Error: Error #2037: Se llamó a las funciones en una secuencia incorrecta o la llamada anterior no se produjo correctamente. Necesariamente debo ir al botón 4 o el de apagar para que funcione. El código es el siguiente:
Código :
import flash.events.Event;
import flash.media.Sound;
import flash.net.URLRequest;
import flash.media.SoundMixer;
var Sonido1:Sound = new Sound();
var mySoundChannel:SoundChannel = new SoundChannel();
var Sonido2:Sound = new Sound();
var mySoundChannel2:SoundChannel = new SoundChannel();
var Sonido3:Sound = new Sound();
var mySoundChannel3:SoundChannel = new SoundChannel();
btn_onda1.addEventListener(MouseEvent.CLICK,onda);
btn_onda2.addEventListener(MouseEvent.CLICK,onda);
btn_onda3.addEventListener(MouseEvent.CLICK,onda);
btn_onda4.addEventListener(MouseEvent.CLICK,onda);
function onda(e:Event):void
{
switch (SimpleButton(e.target))
{
case btn_onda1 :
SoundMixer.stopAll();
Sonido1.load(new URLRequest("Vent.mp3"));
mySoundChannel = Sonido1.play(0);
gotoAndPlay(2);
break;
case btn_onda2 :
SoundMixer.stopAll();
Sonido2.load(new URLRequest("Vent2.mp3"));
mySoundChannel2 = Sonido2.play(0);
gotoAndPlay(3);
break;
case btn_onda3 :
SoundMixer.stopAll();
Sonido3.load(new URLRequest("Vent3.mp3"));
mySoundChannel3 = Sonido3.play(0);
gotoAndPlay(4);
break;
case btn_onda4 :
Sonido1 = null;
Sonido2 = null;
Sonido3 = null;
SoundMixer.stopAll();
gotoAndPlay(1);
break;
}
}
Espero me puedan ayudar Gracias
