Variables and buttons?

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

This should work. Remove all the previous code.

for (var i = 1; i<=3; ++i) {
	this["button_"+i].i = i;
	this["button_"+i].stop();
	this["button_"+i].onRollOver = function() {
		this.gotoAndStop("_over");
	};
	this["button_"+i].onRollOut = function() {
		this.gotoAndStop("_out");
	};
	this["button_"+i].onPress = function() {
		this.gotoAndStop("_press");
	};
	this["button_"+i].onRelease = function() {
		this.enabled = false;
		this.useHandCursor = false;
		this._parent.holder1.loadMovie("image_"+this.i+".swf");
		for (var i = 1; i<=3; ++i) {
			if (this._parent["button_"+i]._name != this._name) {
				this._parent["button_"+i].enabled = true;
				this._parent["button_"+i].useHandCursor = true;
				this._parent["button_"+i].gotoAndStop("_up");
			}
		}
	};
}

claudio,
thanks for your help. It isn’t working.
I have posted a sample file, perhaps you could take a look at it?

Thank you so much.

Its not working because you didnt use the exactly code i posted. There were some typos. Paste the exactly code I gave you on my previous post.

Ahhh,
You rock! Thank you so much!

Welcome =)