Despite my readings I'm still limited in javascipt / soundJS syntax with using flash html5 canvas. I would like to pause and resume my sound with mouseover and mouseout events on the same button. I mean:
According to the SoundInstance Class doc, you can do that with
myInstance.pause();
and myInstance.resume();
methods. And I suppose "var sound;" behaves likes "myInstance" since sound.pause();
works.
With the js code below I can pause the sound and resume my sound, but not on the same button, I need a button_2 to do that.
I think I'm missing a condition in mouseover function to "check if the sound is paused or not and then resume it or start playing.
var sound;
function fl_MouseOverHandler(){
sound = playSound("monstres");
}
this.mybutton.addEventListener("mouseover", fl_MouseOverHandler);
function fl_MouseOutHandler() {
sound.pause();
}
this.mybutton.addEventListener("mouseout", fl_MouseOutHandler);
function fl_MouseOverHandler_2(){
sound.resume();
}
this.mybutton_2.addEventListener("mouseover", fl_MouseOverHandler_2);
Any hint or link is welcome. Thank you.
what about something like this?
var isPlaying = false;
function togglePlayback(){
if(isPlaying){
isPlaying = false;
sound.pause();
} else {
isPlaying = true;
sound.resume();
}
}
this.some_button.addEventListener("some_event", togglePlayback );