# Motion Easing with AS

**URL:** <https://forum.kirupa.com/t/motion-easing-with-as/39991>\
**Category:** flash\
**Created:** [January 13, 2004, 4:24pm UTC](https://forum.kirupa.com/t/motion-easing-with-as/39991 "2004-01-13T16:24:49Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Monabizi](https://avatars.discourse-cdn.com/v4/letter/m/4491bb/32.png) [@Monabizi](https://forum.kirupa.com/u/Monabizi)\
**Post date:** [January 13, 2004, 4:24pm UTC](https://forum.kirupa.com/t/motion-easing-with-as/39991/1 "2004-01-13T16:24:49Z")

</div>

Hi,  
how do i can i adjust the Easing property of moving MC when im moving the MC with AS (not with motion tween) ?!

i got an MC and im increasing it’s \_x by 1 till the \_x got to 100.  
how can i adjust the easing, so that when it become close to 100 it will slowly stopped?

anyone?

---

<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:** [February 6, 2004, 6:50pm UTC](https://forum.kirupa.com/t/motion-easing-with-as/39991/2 "2004-02-06T18:50:15Z")

</div>

Voetsjoeba,

Your golden formula is so beautiful that when I looked upon it, sparrows began landing around me and singing while plum trees blossomed.

Nice work!

lrhb :hat:

---

<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:** [February 6, 2004, 7:49pm UTC](https://forum.kirupa.com/t/motion-easing-with-as/39991/3 "2004-02-06T19:49:31Z")

</div>

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:** [February 12, 2004, 5:52pm UTC](https://forum.kirupa.com/t/motion-easing-with-as/39991/4 "2004-02-12T17:52:59Z")

</div>

Oh, one question…

I used this prototype applied to some object moving along the X axis, and later in the movie I try to move them along the Y axis using tweening, but they don’t go…

Does this somehow hijack the mobility of the object its used on? Or should I make another prototype for the Y axis along these same lines?

Thanks!

lrhb :hat:

---

<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:** [February 12, 2004, 7:34pm UTC](https://forum.kirupa.com/t/motion-easing-with-as/39991/5 "2004-02-12T19:34:19Z")

</div>

That prototype was modified for use with the X axis only. Here’s the prototype that can ease both. You can actually ease any property with this code.

```auto

 MovieClip.prototype.ease = function(x,y){
         this.onEnterFrame = function(){
                 this._x = x-(x-this._x)/1.1;
 this._y = y-(y-this._y)/1.1
                 if(this._x > x-1 && this._x < x+1 && this._y > y-1 && this._y < y+1){
 this._x = x;
 this._y = y;
                         delete this.onEnterFrame
                         //do other stuff here, this is the point at which the object reaches its target
                 }
         }
 }
 MC.ease(100,100);
 

```

---

<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:** [February 12, 2004, 7:39pm UTC](https://forum.kirupa.com/t/motion-easing-with-as/39991/6 "2004-02-12T19:39:20Z")

</div>

Sweet weepin’ Jesus on the cross!

You win!! 🙂

lrhb

---

<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:** [February 12, 2004, 8:20pm UTC](https://forum.kirupa.com/t/motion-easing-with-as/39991/7 "2004-02-12T20:20:19Z")

</div>

Cool, what do I win ? … 😛

You’re welcome, mate 😉

---

<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:** [July 7, 2004, 8:22am UTC](https://forum.kirupa.com/t/motion-easing-with-as/39991/8 "2004-07-07T08:22:54Z")

</div>

Good sample Industriality Thank you! but someone can tell me how to move an object not on x or y but on [FONT=Arial Black][COLOR=Red]diagonal[/COLOR][/FONT]?

_Lobo_

> [@Industriality](#):
>
> If anyone is interested, I expanded a bit on Voetsjoeba’s code in order to add a “round” attribute, and a “speed” attribute. This is very useful when you need to ease a movieclip that uses Pixel fonts, or fonts that look best on whole pixels. Here are the two functions:
> 
> ```auto
> 
> MovieClip.prototype.easeX = function(to,speed,round){
> this.onEnterFrame = function(){
> if(round!=true){
> this._x += (to - this._x)/speed;
> } else {
> this._x += Math.round((to - this._x)/speed);
> }
> if(this._x > to-1 && this._x < to+1){
> this._x = to;
> delete this.onEnterFrame
> //do other stuff here, this is the point at which the object reaches its target
> }
> }
> }
> MovieClip.prototype.easeY = function(to,speed,round){
> this.onEnterFrame = function(){
> if(round!=true){
> this._y += (to - this._y)/speed;
> } else {
> this._y += Math.round((to - this._y)/speed);
> }
> if(this._y > to-1 && this._y < to+1){
> this._y = to;
> delete this.onEnterFrame
> //do other stuff here, this is the point at which the object reaches its target
> }
> }
> }
>  
> 
> ```
> 
> **Usage Examples:**  
> [size=1]mc.easeX(mc.\_x-100,5,true); // Move mc 100 pixels left, on solid pixels, at “5” speed[/size]  
> [size=1]mc.easeX(mc.\_x+100,10,false); // Move mc 100 pixels right, smoothly, at “10” speed[/size]  
> [size=1]mc.easeY(mc.\_y-100,5,true); // Move mc 100 pixels up, on solid pixels, at “5” speed[/size]  
> [size=1]mc.easeY(mc.\_y+100,10,false); // Move mc 100 pixels down, smoothly, at “10” speed[/size]  
> [size=1]mc.easeX(100,5,true); // Move mc to an X of 100, on solid pixels, at “5” speed[/size]  
> [size=1]mc.easeY(100,5,true); // Move mc to a Y of 100, on solid pixels, at “5” speed[/size]  
> [size=1]mc.easeX(100,10,false); // Move mc to an X of 100, smoothly, at “10” speed[/size]  
> [size=1]mc.easeY(100,10,false); // Move mc to a Y of 100, smoothly, at “10” speed[/size]

---

<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:** [July 8, 2004, 9:00am UTC](https://forum.kirupa.com/t/motion-easing-with-as/39991/9 "2004-07-08T09:00:19Z")

</div>

:tb: anyone ? help plz

---

<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:** [July 12, 2004, 8:30am UTC](https://forum.kirupa.com/t/motion-easing-with-as/39991/10 "2004-07-12T08:30:07Z")

</div>

?

---

<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:** [July 19, 2004, 11:15pm UTC](https://forum.kirupa.com/t/motion-easing-with-as/39991/11 "2004-07-19T23:15:35Z")

</div>

MAn… I typed a whole paragraph and then my isp wasn’t working, it got whiped.

I’m going to keep it to main points, so excuse me.

1. I’m used to mIRC’s scripting language where variables are %variable and identifiers are $identifier, the whole system is a bit different… so I’m not the greatest with action script anymore
2. I was never good with AS to begin with, all I could really do is work with the basic functions they give you… :sigh:
3. I want to understand Voetsjoeba’s script better, the MovieClip… is that pertaining to movieclip features by defining so, he put MovieClip. in the beginning? Also… what about the MC.easex at the end, is that “MC” changeable? And where am I putting this code, keyframe? I don’t see any onclipevent’s 😕

Hey thanks for the reading

---

<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:** [July 19, 2004, 11:22pm UTC](https://forum.kirupa.com/t/motion-easing-with-as/39991/12 "2004-07-19T23:22:50Z")

</div>

to move it on a diagonal you should use x and y, just have both increase proportionately (sp?). Like have x and y both 100 if you’re starting on 0 and it’ll move diagonally

---

<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:** [July 21, 2004, 7:53am UTC](https://forum.kirupa.com/t/motion-easing-with-as/39991/13 "2004-07-21T07:53:47Z")

</div>

Thank you I will try that ! 🍺

---

<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:** [July 21, 2004, 8:20am UTC](https://forum.kirupa.com/t/motion-easing-with-as/39991/14 "2004-07-21T08:20:25Z")

</div>

var easeInKnob =  
var easeOutKnob =  
Was it wrong for me to laugh like a 10-year old schoolboy when I read this?

Maybe it’s just my British sense of humour.
