My problem is that I have an option page which contains the button to control the background music on and off. it works fine. But when I exit the option page then go back to option page again and play the music again, there will be two sound playing and if I stop it, only one sound will stop and the other one keeps on playing.
Here is my code please help me fix this thing thanks :) By the way Im using AS3.
> [ OPTION ] () is the on and off button of my music
> [ MUSIC: () ] when I on the music it plays
> [ ] then when I go to the main menu, the music plays well
> [ BACK ] no problem in this part
> [ ] in the main menu, music is playing well
> [ MAIN MENU ] if I go to the option page again
> [ ] ....................
> [ PLAY OPTION ETC ]
> [ ] Here it goes, when I click the on and off button again to stop the music
> [ MUSIC: () ] It didnt stop, instead it plays another music
> [ ] So my problem is that. Please help me solve this
> [ BACK ]
on_off_btn.addEventListener(MouseEvent.CLICK, fl_ClickToPlayStopSound); // on_off_btn is the instance name
//This variable keeps track of whether you want to play or stop the sound
var fl_ToPlay:Boolean = true;
var s:Sound = new Sound(new URLRequest("harry.MP3"));
fl_SC = s.play();
fl_ToPlay = !fl_ToPlay;