How to stop sound from playing everytime we go to 1st frame ?*
Hi everyone, my app has 3 frames and a sound playing on background so everytime i go to 1st frame the music play's over himself,
is easy to get 5 instances of the music playing at same time.
How to stop this behavior ?
Music file imported to library.
Sound Linkage: export for actionScript
Sound Linkage: export in frame 1
Any help are welcome ![]()
Flash CS6 - AIR 3.4 Android and iOS > CODE:
//sound
var bgSound:BGLoop = new BGLoop();
var channel:SoundChannel=new SoundChannel();
playMusic();
//making mute;
soundBtn.addEventListener(MouseEvent.MOUSE_UP , mute);
function mute(event:MouseEvent) {
//removing mute function then adding unmute function to same button
soundBtn.removeEventListener(MouseEvent.MOUSE_UP , mute);
soundBtn.addEventListener(MouseEvent.MOUSE_UP , unMute);
//making symbol to visible;
soundBtn.gotoAndStop(2);
//set the volume false;
SoundMixer.soundTransform = new SoundTransform(0);
}
//making unmute
function unMute(event:MouseEvent) {
soundBtn.removeEventListener(MouseEvent.MOUSE_UP , unMute);
soundBtn.addEventListener(MouseEvent.MOUSE_UP , mute);
soundBtn.gotoAndStop(1);
//set the volume true;
SoundMixer.soundTransform = new SoundTransform(1);
}
function playMusic():void {
channel = bgSound.play();
channel.addEventListener(Event.SOUND_COMPLETE, loopMusic);
}
function loopMusic(e:Event):void {
if (channel != null) {
channel.removeEventListener(Event.SOUND_COMPLETE, loopMusic);
playMusic();
}
}
