# Using variables to show/hide buttons - why doesn't this work?

**URL:** https://forum.kirupa.com/t/using-variables-to-show-hide-buttons-why-doesnt-this-work/187728
**Category:** flash
**Created:** [May 1, 2006, 10:31pm UTC](https://forum.kirupa.com/t/using-variables-to-show-hide-buttons-why-doesnt-this-work/187728 "2006-05-01T22:31:33Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tsunchoo](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@tsunchoo](https://forum.kirupa.com/u/tsunchoo)
#### Post date: [May 1, 2006, 10:31pm UTC](https://forum.kirupa.com/t/using-variables-to-show-hide-buttons-why-doesnt-this-work/187728/1 "2006-05-01T22:31:33Z")

</div>

```auto
	var showbutton="buttonone";
	var currentpage="pageone";
	this[showbutton]._visible = false;
	
buttonone.onRelease = function() {
	if(currentpage != "pageone"){		
	this[showbutton]._visible = true;
	buttonone._visible = false;
	trace(showbutton);
	showbutton = "buttonone";
	}
};

buttontwo.onRelease = function() {
	if(currentpage != "pagetwo"){
	this[showbutton]._visible = true;
	trace(showbutton);
	buttontwo._visible = false;
	showbutton = "buttontwo";
	}
};

```

so the idea is just that when you click one button the other disappears  
and vice versa - what i don’t get is that the code at the top which makes  
the button disappear works - then when i try to do it within the if…else statement it doesn’t. trace shows that the variable is correct…errrrrr

please help…i no understandie

:red:
