# Function stops executing

**URL:** https://forum.kirupa.com/t/function-stops-executing/130785
**Category:** Uncategorized
**Created:** [December 8, 2004, 4:07pm UTC](https://forum.kirupa.com/t/function-stops-executing/130785 "2004-12-08T16:07:08Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![H4T](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/h4t/32/329_2.png) [@H4T](https://forum.kirupa.com/u/H4T)
#### Post date: [December 8, 2004, 4:07pm UTC](https://forum.kirupa.com/t/function-stops-executing/130785/1 "2004-12-08T16:07:08Z")

</div>

I have a function and a movieclip prototype. When the prototype applies an onEnterFrame to an mc, it repeatedly calls the function (hitTests for all other mcs). Besides this, it also eases the mc to a new point. However, when the mc have reached this point, the function handling the hitTests stops being called. Why?

```php
// Prototype....
MovieClip.prototype.moveSprite = function(speed, spriteType) {
 // Generate random coordinates
 var tarX = Math.round(Math.random()*(400-this._width/2)+this._width/2);
 var tarY = Math.round(Math.random()*(300-this._width/2)+this._width/2);
 
 this.onEnterFrame = function() {
   // Ease to new coordinates
   var distX = tarX - this._x;
   var distY = tarY - this._y;
   
   this._x += distX/speed;
   this._y += distY/speed;

   liveLike(spriteType);
 }
}
// Function (hitTests were replaced with trace....it does indeed trace until it is halted by the prototype..
liveLike = function(spriteType) {
 if(spriteType == "carn") {
  trace(spriteType);
 } else if(spriteType == "herb") {
  //trace(this._name);
 } else if(spriteType == "omni") {
  //trace(this._name);
 }
}

```

The function should trace “carn” over and over and over, but instead, it traces “carn” over and over until the prototype picks a new point to ease to. Makes no sense to me, can anyone PLEASE help? (This is a class independant study that must be finished in 10 days, lol).
