# Button code being a real pain - easy one!

**URL:** <https://forum.kirupa.com/t/button-code-being-a-real-pain-easy-one/187799>\
**Category:** Uncategorized\
**Created:** [May 2, 2006, 1:26pm UTC](https://forum.kirupa.com/t/button-code-being-a-real-pain-easy-one/187799 "2006-05-02T13:26:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flashsandy](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@flashsandy](https://forum.kirupa.com/u/flashsandy)\
**Post date:** [May 2, 2006, 1:26pm UTC](https://forum.kirupa.com/t/button-code-being-a-real-pain-easy-one/187799/1 "2006-05-02T13:26:34Z")

</div>

```auto
	var gallery="galleryone";
	var button="tabone";

buttons.tabtwo.buttontwo.onRelease = function() {

	_root.galleries[gallery].gotoAndPlay(2);
	buttons[button].gotoAndPlay(22);
	buttons.tabtwo.gotoAndPlay(2);
	gallery = "gallerytwo";
	button = "buttontwo";

};

buttons.tabone.buttonone.onRelease = function() {

	_root.galleries[gallery].gotoAndPlay(2);
	buttons[button].gotoAndPlay(22);
	buttons.tabone.gotoAndPlay(2);
	gallery = "galleryone";
	button = "buttonone";
	
};

```

Ok- so the idea is that when you click a button it plays the movies assigned to the variables **gallery** & **button** to the frames mentioned.

Then the variables are changed and then when another buttons is clicked it does the same - 'except it doesn’t - it does it once then sits there ;(

I have to use variables because there’s a lot more buttons…but i don’t understand why it doesn’t work - it seems such a simple and obvious thing to try and do - why is it so HARD???

help me…

:p:
