title: Strange javascript behaviour - error unless 'classes' are defined in correct order
body: <p>I have a very strange problem with javascript and easel js.</p>
  
  <p>I am using the easel.js library and am already fairly far into the construction of a project using it.</p>
  
  <p>I am attempting to have a 'class' (I know they aren't technically classes in javascript but I will use this terminology for lack of a better word) inherit the Shape class from easel js, and then have another class inherit that. So it would be something like this:</p>
  
  <p>easeljs.Shape --> MenuButton --> BuildingButton</p>
  
  <p>The code I am using looks like this:</p>
  
  <pre><code>BuildingButton.prototype = Object.create(MenuButton.prototype);
  BuildingButton.prototype.constructor = BuildingButton;
  
  function BuildingButton(){
      MenuButton.call(this);
  }
  
  MenuButton.prototype = Object.create(createjs.Shape.prototype);
  MenuButton.prototype.constructor = MenuButton;
  
  function MenuButton(){
      createjs.Shape.call(this);
  }
  </code></pre>
  
  <p>The problem is that I get the following error with this code:</p>
  
  <pre><code>Uncaught TypeError: undefined is not a function 
  easeljs-0.7.1.combined.js:8439
  </code></pre>
  
  <p>(line 8439 is pointing to the initialize() function in the Shape() constructor).</p>
  
  <p>now here's the strange thing. If I change the order of the definitions so that the sub class is defined second and not first, it works fine!</p>
  
  <pre><code>MenuButton.prototype = Object.create(createjs.Shape.prototype);
  MenuButton.prototype.constructor = MenuButton;
  
  function MenuButton(){
      createjs.Shape.call(this);
  }
  
  BuildingButton.prototype = Object.create(MenuButton.prototype);
  BuildingButton.prototype.constructor = BuildingButton;
  
  function BuildingButton(){
      MenuButton.call(this);
  }
  </code></pre>
  
  <p>This is very confusing as I can't seem to figure out why on earth this is happening. I could just make sure I define them in the correct order and leave it be, but I have all my 'classes' in different source files which are then strung together by grunt, which does so alphabetically.
  Also, I feel like I may have a big gap in my knowledge of javascript (or maybe easel.js I'm not sure what exactly is causing this behaviour).</p>
  
  <p>Thanks in advance for your help and I hope the question makes sense!</p>