title: change javascript object's method on the fly
body: <p>I have a javascript object called Button. This is an object on a HTML5 canvas, and changes it's color when the mouse enters it:</p>
  
  <pre><code>Button.prototype.handleMouseMove = function() {
      if(this.isMouseOver() &amp;&amp; !this.mouseIsOver) {this.onMouseIn(); this.mouseIsOver = true;}
      if(!this.isMouseOver() &amp;&amp; this.mouseIsOver) {this.onMouseOut(); this.mouseIsOver = false;}
  }
  
  Button.prototype.onMouseIn = function() {
      this.setColor("red");
  }
  </code></pre>
  
  <p>I'd like to change onMouseIn method on the fly,but I don't really know how to do it.</p>
  
  <p>I've tried:</p>
  
  <pre><code>button1.onMouseIn = button1.setColor("xy");
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Button.prototype.changeMouseInAction(fn) {
      this.onMouseIn = fn;
  }
  button1.changeMouseInAction(button1.setColor("xy"));
  </code></pre>
  
  <p>but nothing works.</p>