MoveTo Function

Hello,

I am working on a simple eportfolio for one of my college classes. I am trying to made one movieclip (instance: main) move horizontally when you click on buttons. I have two buttons one of the left side of the the stage (Instance: show) that slides “main” to the right; and one of the right side of the stage (instace: hide) that slides “main” to the left.

Problem:

According to my script now, I can only move the movie once to a defines x-value. How can I get it so when the button is clicked it continues to move “main” multiple times?

Code:


function MoveTo (clip, fadeType, xTo, yTo, speed) {
	clip.onEnterFrame = function () {
		this._x += (xTo -this._x) * speed;
		this._y += (yTo - this._y) * speed;
		if (fadeType == "in" && this._alpha <100){
			this._alpha += 5;
		}else if (fadeType == "out" && this._alpha >0) {
			this.alpha -=5;
		}
	};
}

show.onPress = function () {
	MoveTo (main, "in", 160, 40, 0.3);
};

hide.onPress = function () {
	MoveTo (main, "out", -450, 40, 0.3);
};