How to use function to generate buttons

Im very new to AS3 and trying to figure some things out. Im sure there is an easy way to accomplish what im doing.

I want to make generating the code for my movie clip buttons. This is what I have right now:

// Button 1 code
but1.buttonMode = true;
but1.useHandCursor = true;
but1.addEventListener(MouseEvent.ROLL_OVER, but1rollover);
but1.addEventListener(MouseEvent.ROLL_OUT, but1rollout);
but1.addEventListener(MouseEvent.CLICK, but1click);

function but1rollover (myevent:MouseEvent){
	but1.gotoAndPlay(2);
}
function but1rollout (myevent:MouseEvent){
	but1.gotoAndPlay('finish');
}
function but1click (myevent:MouseEvent){
	this.mystate="one";
	this.nextFrame();
}

// Button 2 code
but2.buttonMode = true;
but2.useHandCursor = true;
but2.addEventListener(MouseEvent.ROLL_OVER, but2rollover);
but2.addEventListener(MouseEvent.ROLL_OUT, but2rollout);
but2.addEventListener(MouseEvent.CLICK, but2click);

function but2rollover (myevent:MouseEvent){
	but2.gotoAndPlay(2);
}
function but2rollout (myevent:MouseEvent){
	but2.gotoAndPlay('finish');
}
function but2click (myevent:MouseEvent){
	this.mystate="two";
	this.nextFrame();
}

I’ve tried to create a function for this, it seems to work but I dont know how to create the mystate variable that is needed for a timeline action to know where to got when the button is clicked. This is the code I have generated but it needs help:

function createbut(var1)  {
	var1.buttonMode = true;
	var1.useHandCursor = true;
	var1.addEventListener(MouseEvent.ROLL_OVER,
		function (myevent:MouseEvent){
		var1.gotoAndPlay(2);
		});
	var1.addEventListener(MouseEvent.ROLL_OUT,
		function (myevent:MouseEvent){
		var1.gotoAndPlay("finish");
		});
	var1.addEventListener(MouseEvent.CLICK,
		function (myevent:MouseEvent){
			var mystate=var1;
		nextFrame();
		});

}
createbut(but1);
createbut(but2);

Any help is much appreciated. Thanks,
Jason