Hi everyone,
I am trying to make a toggling on/off button for a looping sound using AS3. Currently it starts with the on icon showing but when pressed shows the off icon but it must be pressed again to stop the music but then shows the on icon while the music is stopped and vice versa. I also have sound on my navigation buttons that are stopped when the stop icon for the loop is pressed. How can I keep the sounds for the navigation icons to continue to play and get the on/off icons for the loop working? Any help or links to a good tutorial would be great :)
var music:Sound = new Sound(new URLRequest("music.mp3"));
var trans:SoundTransform = new SoundTransform(1, -1);
var channel:SoundChannel = music.play(0, 1000, trans);
var musicOn:Boolean = true
play_btn.addEventListener(MouseEvent.CLICK, onSound);
stop_btn.addEventListener(MouseEvent.CLICK, offSound);
stop_btn.visible = false;
function offSound(e:Event) {
musicOn = false;
play_btn.visible = true;
stop_btn.visible = false;
trans.volume=0;
SoundMixer.soundTransform = trans;
}
function onSound(e:Event) {
musicOn = true;
play_btn.visible = false;
stop_btn.visible = true;
trans.volume=1;
SoundMixer.soundTransform = trans;
}