title: Javascript object function call wont work
body: <p>I'm working on a HTML5 soundboard, but i've hit a bit of a snag...</p>
  
  <p>I'm trying to get a stop function to work on all of the sounds at once that are played. Unfortunatly when i call this function from a buttonpress, the object doesn't appear to have a stop function. The code for the actual sound element is the following:</p>
  
  <pre><code>// Container to keep all sounds in one place. This is a Dictionary within a dictionary to be able to search by catagory.
  var sounds = {};
  
  // Counter to keep track of unique ID's
  var lastID = 0;
  
  
  // Base class for initializing Any class
  var Base = function(methods){
      var base = function() {    
          this.initialize.apply(this, arguments);          
      };  
  
      for (var property in methods) { 
         base.prototype[property] = methods[property];
      }
  
      if (!base.prototype.initialize) base.prototype.initialize = function(){};      
  
      return base;    
  };
  
  //Complete class for the Sound object. Generates its own DIV's and HTML5 tags to play stuff.
  var Sound = Base({ 
      // Init all the variables. 
      initialize: function(name, file, target='Sounds') {
          this.name = name;
          this.file = file
          this.button = null;
          this.audioelement;
          this.id = lastID + 1;
          this.target = target;
          lastID ++;
  
  
          // Check if the catagory is there, if not: create it with a placeholder object
          var catagory = sounds[this.target];
          if(catagory == null){
              sounds[this.target] = {99:null};
  
          }
          sounds[this.target][this.id] = this;
  
          // Call init function
          this.init();
      },
  
      play : function() {
          obj = this
          if(obj.audioelement.paused == true){
              obj.audioelement.play();    
          }else{
              obj.audioelement.pause();
              obj.audioelement.fastSeek(0);
          }
  
      },
      stop : function(){
          obj = this;
          obj.audioelement.pause();
      },
      init : function(){
  
          // Statement for JS class based shenanigans.
          obj = this
  
          // Create a button and add some text to it
          obj.button = document.createElement("BUTTON");
          obj.button.appendChild(document.createTextNode(obj.name));
  
          // Set ID's and names to keep track of this button
          obj.button.id = obj.id;
          obj.button.name = obj.target;
  
          // Get or create parent element. Used for catagory based display
          var el = getOrCreateElement(obj.target)
          el.appendChild(obj.button);
  
          // Create audio element and set appropriate settings
          obj.audioelement = document.createElement("AUDIO");
          obj.audioelement.src = obj.file;
          obj.audioelement.name
          obj.button.appendChild(obj.audioelement);
  
          // Add function to play/pause to button
          obj.button.onclick = buttonClicked;
  
  });
  function buttonClicked(){
      // Fetch sound from dicionary container using the name and id from the button [SET AT SOUND.INIT()]
      var sound = sounds[this.name][this.id];
      // Call the play function in [SOUND]
      sound.play();
  }
  </code></pre>
  
  <p>And for the stopall function:</p>
  
  <pre><code>function stopAll(){
      // Scroll through the entire dictionary
      for ( var key in sounds){
          for ( var id in sounds[key]){
              // Check if the sound is not a placeholder
              if(id == 99){
                  continue;
              }
              // Call stop function with fetched object.
              var sound = sounds[key][id];
              sound.stop();
          }
      }
  }
  </code></pre>
  
  <p>The weird thing is is that the play function does seem to work, but not the stop function. It says that the object doesn't have that specific function...</p>
  
  <p>Any ideas would be appriciated!</p>
  
  <p>WM</p>