# Variables and buttons?

**URL:** <https://forum.kirupa.com/t/variables-and-buttons/101269>\
**Category:** Uncategorized\
**Created:** [February 8, 2004, 12:54am UTC](https://forum.kirupa.com/t/variables-and-buttons/101269 "2004-02-08T00:54:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bubba1](https://avatars.discourse-cdn.com/v4/letter/b/b3f665/32.png) [@bubba1](https://forum.kirupa.com/u/bubba1)\
**Post date:** [February 8, 2004, 12:54am UTC](https://forum.kirupa.com/t/variables-and-buttons/101269/1 "2004-02-08T00:54:24Z")

</div>

Hi,  
I have a movie clip button that has 3 states:  
up, over, out, and press.  
the action script inside the movie clip button looks like this:

stop();  
onRollOver = function () {  
this.gotoAndstop("\_over");  
};  
onRollOut = function () {  
this.gotoAndstop("\_out");  
};  
onPress = function () {  
this.gotAndstop("\_press");  
};

on the stage, I have several instances of this button mc.  
when the button is clicked, it loads an external file into a container on the stage.

the action script looks like this:

button\_1.onRelease = function() {  
\_root.holder1.loadMovie(“image\_1.swf”);  
\_root.button\_1.enabled = false;  
this.useHandCurser = false;  
\_root.button\_2.enabled = true;  
\_root.button\_2.gotoAndStop("\_up");  
\_root.button\_3.enabled = true;  
\_root.button\_3.gotoAndStop("\_up");  
};

button\_2.onRelease = function() {  
\_root.holder1.loadMovie(“image\_2.swf”);  
\_root.button\_2.enabled = false;  
this.useHandCurser = false;  
\_root.button\_1.enabled = true;  
\_root.button\_1.gotoAndStop("\_up");  
\_root.button\_3.enabled = true;  
\_root.button\_3.gotoAndStop("\_up");  
};

button\_3.onRelease = function() {  
\_root.holder1.loadMovie(“image\_3.swf”);  
\_root.button\_3.enabled = false;  
this.useHandCurser = false;  
\_root.button\_1.enabled = true;  
\_root.button\_1.gotoAndStop("\_up");  
\_root.button\_2.enabled = true;  
\_root.button\_2.gotoAndStop("\_up")  
};

and so on.

Now, I have 12 buttons for each section. Is there a better way to do this with variables?  
If you can help me I’d really appreciate it.

thank you
