All happy people out there,
need your help regarding my sound
So far I can load and play my sound in my main keyframe, the problem is when I want to make the sound off by clicking a checkbox_mc to make it off,its not working
I wonder if its caused by my structure
This is my code;
on the first keyframe
var Music:Sound = new Sound();
var musicChannel:SoundChannel;
var url:String = “sound/intro.mp3”;
var req:URLRequest = new URLRequest(url);
Music.load(req);
Music.play();
then when I clicked option button(same keyframe), I will unticked the checkbox(next keyframe) to make the music stop playing.
I used this code;
var isPlaying:Boolean = true;
function onCheck(evt:MouseEvent):void {
switch (evt.target) {
case mainOption_mc.ok_btn :
gotoAndPlay(“menu”);
break;
case mainOption_mc.checkboxMusic_mc :
if(isPlaying == true) {
musicChannel.stop();
mainOption_mc.checkboxMusic_mc.gotoAndPlay(“unticked”);
isPlaying = false;
}else {
musicChannel= Music.play();
mainOption_mc.checkboxMusic_mc.gotoAndPlay(“ticked”);
isPlaying = true;
}
break;
case mainOption_mc.checkboxFullscr_mc :
gotoAndPlay(“unticked”);
break;
}
}
Th eoutput I get now is that my musicChannel is a null object.
So I put var musicChannel:SoundChannel; again inside the function
however, it still said my musicChannel is null
I don’t get it -.-
I realized as I researched that SoundChannel in AS should be reannounced in every new keyframe since AS3 can’t keep it, no?
Can anyone give me a direction to fix this problem?
Thanks in advanced.