# Creating movement

**URL:** <https://forum.kirupa.com/t/creating-movement/15978>\
**Category:** Uncategorized\
**Created:** [March 19, 2003, 10:08pm UTC](https://forum.kirupa.com/t/creating-movement/15978 "2003-03-19T22:08:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimw00d](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jimw00d](https://forum.kirupa.com/u/jimw00d)\
**Post date:** [March 19, 2003, 10:08pm UTC](https://forum.kirupa.com/t/creating-movement/15978/1 "2003-03-19T22:08:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 20, 2003, 12:39pm UTC](https://forum.kirupa.com/t/creating-movement/15978/2 "2003-03-20T12:39:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 20, 2003, 1:06pm UTC](https://forum.kirupa.com/t/creating-movement/15978/3 "2003-03-20T13:06:13Z")

</div>

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??

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 20, 2003, 2:06pm UTC](https://forum.kirupa.com/t/creating-movement/15978/4 "2003-03-20T14:06:52Z")

</div>

take **eg** ’s file and throw this code in it 🙂

```auto
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?
