Mute all button sounds

So this is related to this post.

This is not a mute as such. Just a check box.

I have adapted here to be a persistent symbol.

All this does is simple sets a global var to true or false.

When you then go to a scene and the play scripts are called then they will check what the globals value is and play or not play.

the mute var is inited in initMute() on symbol load .

	 if(typeof  window.muteAll   == "undefined") {  window.muteAll   = false
	 
	 
	 
	 console.log(  window.muteAll );
	 
	 }

When the checkbox is clicked, the symbol runs it's
selection() function.

This animates the check box and sets the global var....

	var thisSelection = hypeDocument.getSymbolInstanceById( (element.closest('.checkboxGroup').parentElement.closest('.HYPE_element').id)).symbolName()
 
	//var thisSelection = element.title //-- get the Title/alt Text of the check group.
	var selectionTick = element.querySelector('.tick')//-- find the tick image for this symbol
	var selectionTickState = hypeDocument.getElementProperty(selectionTick, 'opacity') //-- get the tick image opacity
 	 


selectionTickState === 0 ? (
    hypeDocument.setElementProperty(selectionTick, 'opacity', 1), //-- show tick
     window.muteAll  = true //-- add item reference to array

) : (
	
    hypeDocument.setElementProperty(selectionTick, 'opacity', 0),  
   
  window.muteAll  = false //-- remove item reference to array using the index
);

...ready for when you try to play a sound

	 if (! window.muteAll ){
	var a = new Audio("${resourcesFolderName}/blahasblog_ladaengine.mp3");
a.play();
 }	

blahasblog_example_scenes_js._MHv1.hype.zip (2.3 MB)


Note I commented out the code in LOAD_Audio().

This was producing fatal error.

3 Likes