# Easing movement, arrow controls

**URL:** <https://forum.kirupa.com/t/easing-movement-arrow-controls/35093>\
**Category:** Uncategorized\
**Created:** [November 10, 2003, 1:56pm UTC](https://forum.kirupa.com/t/easing-movement-arrow-controls/35093 "2003-11-10T13:56:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![macneilslt](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@macneilslt](https://forum.kirupa.com/u/macneilslt)\
**Post date:** [November 10, 2003, 1:56pm UTC](https://forum.kirupa.com/t/easing-movement-arrow-controls/35093/1 "2003-11-10T13:56:22Z")

</div>

i have a ball i want to move around so i used the following AS to move it:

[AS]

onClipEvent(load) {  
setProperty(this, \_x, 375);  
setProperty(this, \_y, 375);  
moveSpeed = 10;

}

onClipEvent(enterFrame) {

```
if(Key.isDown(key.RIGHT) and this._x &lt; 375) {
	this._x += moveSpeed;
	
	
}
if(key.isDown(key.LEFT) and this._x &gt; 25) {
	this._x -= moveSpeed;
	
}
if(key.isDown(key.UP) and this._y &gt; 25) {
	this._y -= moveSpeed;
}
if(key.isDown(key.DOWN) and this._y &lt; 375) {
	this._y += moveSpeed;
}

```

}

[/AS]

i wanted to add an easing motion, as if it was in water, or something like that so i read a tutorial on easing on this sight and tried…

[AS]

onClipEvent(load) {  
setProperty(this, \_x, 375);  
setProperty(this, \_y, 375);  
moveSpeed = 10;

}

onClipEvent(enterFrame) {

```
if(Key.isDown(key.RIGHT) and this._x &lt; 375) {
	this._x += moveSpeed;
	_x += (endX-_x)/Movespeed;
	
}
if(key.isDown(key.LEFT) and this._x &gt; 25) {
	this._x -= moveSpeed;
	
}
if(key.isDown(key.UP) and this._y &gt; 25) {
	this._y -= moveSpeed;
}
if(key.isDown(key.DOWN) and this._y &lt; 375) {
	this._y += moveSpeed;
}

```

}

[/AS]  
as you can see i only tried it on the right movement, although i wanted it on all movements, but it didn’t really work…  
any help/ pointers in the right direction would be appriciated,  
thanks 🙂

---

<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:** [November 10, 2003, 2:11pm UTC](https://forum.kirupa.com/t/easing-movement-arrow-controls/35093/2 "2003-11-10T14:11:52Z")

</div>

something like:

[AS]  
this.\_x += moveSpeed/2;  
[/AS]

should work. Just change how much you divide it by to get different effects 🙂

you can use endX because it is a variable and you havn’t declared it as anything.

---

<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:** [November 10, 2003, 2:17pm UTC](https://forum.kirupa.com/t/easing-movement-arrow-controls/35093/3 "2003-11-10T14:17:28Z")

</div>

doesn’t seem to give the effect i’m looking for…  
have you ever been to [www.xgenstudios.com/](http://www.xgenstudios.com/)

theres a game there called fishy, you swim this little fish around, and when you go to stop he kind of drifts a little, since you can’t really instantly stop in the water

---

<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:** [November 10, 2003, 2:32pm UTC](https://forum.kirupa.com/t/easing-movement-arrow-controls/35093/4 "2003-11-10T14:32:08Z")

</div>

i guess you need physics stuff then like acceleration formula, gravity and all that stuff. If i come up with it i’ll tell you but probalby wont’ be soon :-\

---

<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:** [November 10, 2003, 3:50pm UTC](https://forum.kirupa.com/t/easing-movement-arrow-controls/35093/5 "2003-11-10T15:50:51Z")

</div>

hmm, i’ll look into that
