function Animator (stepMethod, finishMethod, object) {
  this.I = null;
  this.stepMethod = stepMethod;
  this.finishMethod = finishMethod;
  this.object = object;
}

Animator.prototype.run = function(int) {
  var T = this;
  function frame () {
    if (T.stepMethod.call(T.object) === false)
      T.stop();
  }

  if (this.I === null)
    this.I = setInterval(frame, int);
}

Animator.prototype.stop = function() {
  if (this.I !== null) {
    clearInterval(this.I);
    if (this.finishMethod)
      this.finishMethod.call(this.object)
    this.I = null;
  }
}
