the code at https://zimjs.com/slate button [HELP] to toggle backgorundmusic seems not working when toggle on/off
it does not toggle the sound out, why?
let backingSound;
const toggle = new Toggle({
label:"music",
startToggled:false
})
.sca(.7)
.pos(40,40,LEFT,BOTTOM)
.change(()=>{
if (!backingSound) {
backingSound = new Aud("https://zimjs.com/assets/backing.mp3").play(.1, true);
}
backingSound.paused = !toggle.toggled;
});
also not this code with an icon sound x
let backingSound;
const button = new Button({
width:60,
height:60,
corner:0,
backgroundColor:purple,
rollBackgroundColor:pink,
icon:makeIcon("sound", white),
toggleIcon:makeIcon("mute", white)
}).pos(50,50,LEFT,BOTTOM).tap(()=>{
if (!backingSound) {
backingSound = new Aud("https://zimjs.org/assets/backing.mp3").play(.1, true);
}
backingSound.paused = !button.toggled;
});