Creating movement

Avoiding tweening what method can I use to get a shape to move from off the stage on the right to a position centre stage. I want to control the speed of the movement and I want to stop the movement after a defined period.

I have tried to use for loops and if conditionals but neither work.

I want the movement to execute on a button press.

i.e. on(press){
movement function ()
}

etc

Can anyone help on this

cheers

You can try something like this, maybe it will give you some idea. I attached an example. =)

I was thinking of something more like this.

Although I can’t figure out how to return the red block to its original position, when say, another button is pressed.

Any ideas??

take eg’s file and throw this code in it :slight_smile:

MovieClip.prototype.move = function(x) {
	this.onEnterFrame = function() {
		if (Math.ceil(this._x) != x) {
			this._x += (x-this._x)/10;
		} else {
			this._x = x;
			delete this.onEnterFrame;
		}
	}
}
buttonMC.onRelease = function() {
	!clicked ? box.move(430) : box.move(170);
	!clicked ? clicked=true : clicked=false;
}

something like that?