title: Uncaught TypeError: undefined is not a function when including javascript class in a seperate file
body: <p>Im new to classes in Javascript, but I trying to create a simple drawing app, with Raphael. The problem I have currently is with some code that works when it is in the same file, but then when I try to take it out and include it, it gives me:</p>
  
  <pre><code>Uncaught TypeError: undefined is not a function. 
  </code></pre>
  
  <p>My first thought was that the file isn't getting included correctly, so I checked, and chrome's dev helper tools show the resource just fine. </p>
  
  <p>The code is in a file called line.js:</p>
  
  <pre><code>function line(paper) {
      this.x1 = null;
      this.x2 = null;
      this.y1 = null;
      this.y2 = null;
  
      this.paper = paper;
  };
  
  line.prototype.draw = function(){
      this.paper.path(
          "M " + this.x1 + " " + this.y1 +
          " l " + (this.x2 - this.x1) + " " + (this.y2 - this.y1) + " z"
      );
  };
  </code></pre>
  
  <p>and the code in question that is using it is:</p>
  
  <pre><code>&lt;script type="text/javascript" src="../js/raphael-min2.1.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="../js/line.js"&gt;&lt;/script&gt;
  
  &lt;script&gt;
  window.onload = function() {  
      var paper = new Raphael($('#canvas')[0], 500, 500);
      var canvas =$('#canvas');    
      var line = new line(paper);
  
      canvas.mousedown(function(e){
          line.x1 = e.offsetX;
          line.y1 = e.offsetY;
      });
  
      canvas.mouseup(function(e){
          line.x2 = e.offsetX;
          line.y2 = e.offsetY;
          line.draw();
      });
  };
  &lt;/script&gt;
  </code></pre>
  
  <p>I've never used classes in javascript before, nor included js files that i've made myself, so any light on the matter, not just a fix would be nice. Also if you think there is a better approach to how Im doing this in general, please let me know! Thanks a lot! </p>