Sound off/on button

I want to make a button that turns sound both on and off so that when the sound is on the button will turn it off and vice versa. I have tried doing this through variables, here is what I did.

Actions for the frame(I want this to create a variable soundon I remember there being a global variable thing how do I do it? I want the movie to check if soundon is true or false and if it is false to stop all sounds if it is true to play all sounds I think I messed up setting the variable) :


var soundon;
_root.soundon = true;
if (_root.soundon=false) {
	stopAllSounds();
}

Actions for the button(I want this to set the soundon variable to false when the sound is on when clicked and true when the sound is on when the button is clicked):


on (press) {
	_root.soundon = false;
}