# \[AS2\]function executes premature with easeX

**URL:** <https://forum.kirupa.com/t/as2-function-executes-premature-with-easex/233762>\
**Category:** flash\
**Created:** [July 26, 2007, 5:38pm UTC](https://forum.kirupa.com/t/as2-function-executes-premature-with-easex/233762 "2007-07-26T17:38:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![neoarch](https://avatars.discourse-cdn.com/v4/letter/n/90db22/32.png) [@neoarch](https://forum.kirupa.com/u/neoarch)\
**Post date:** [July 26, 2007, 5:38pm UTC](https://forum.kirupa.com/t/as2-function-executes-premature-with-easex/233762/1 "2007-07-26T17:38:41Z")

</div>

```auto

////////////
//proto.as//
////////////
MovieClip.prototype.easeX = function( to:Number , speed:Number , endF:Function , endO , endP:Array ){
 
 var _this:MovieClip = this;
 var aux:MovieClip = _this.createEmptyMovieClip( "easeX_aux" , 1223 );
 var previousPosition:Number = this._x;
 
 if( isNaN(speed) || speed == undefined || speed == '' || speed <= 1 ) speed = 1.2;
 if( _this._x != to ){
  aux.onEnterFrame = function(){
   _this._x = to - ( to - _this._x ) / speed;
   if( _this._x == previousPosition ){
    _this._x = to;
    this.removeMovieClip();
    if (endF) {
     endF.apply(endO, endP);
    }
   }
   previousPosition = _this._x;
  }
 } else {
  if (endF) {
     endF.apply(endO, endP);
    }
 }
}

```

```auto

#include "proto.as"
 
function eventOver():Void {
myClip_mc.easeX( frame_mc._x + 230, otherFunction());
}
 
 
otherFunction = function() {
    etc.
    etc.
}

```

otherFunction() runs as soon as the mouse over happens and not after the ease finishes as I would like it to. ☹
