examples/sprite/sprite.js
function(key) {
    var self = this;
    var sprite = self._spriteMap[key];

    // Play the sprite sound and capture the ID.
    var id = self.sound.play(sprite);

    // Create a progress element and begin visually tracking it.
    var elm = document.createElement('div');
    elm.className = 'progress';
    elm.id = id;
    elm.dataset.sprite = sprite;
    window[key].appendChild(elm);
    self.sounds.push(elm);

    // When this sound is finished, remove the progress element.
    self.sound.once('end', function() {
      var index = self.sounds.indexOf(elm);
      if (index >= 0) {
        self.sounds.splice(index, 1);
        window[key].removeChild(elm);
      }
    }, id);
  }
function(key) {
    var self = this;
    var sprite = self._spriteMap[key];

    // Play the sprite sound and capture the ID.
    var id = self.sound.play(sprite);

    // Create a progress element and begin visually tracking it.
    var elm = document.createElement('div');
    elm.className = 'progress';
    elm.id = id;
    elm.dataset.sprite = sprite;
    window[key].appendChild(elm);
    self.sounds.push(elm);

    // When this sound is finished, remove the progress element.
    self.sound.once('end', function() {
      var index = self.sounds.indexOf(elm);
      if (index >= 0) {
        self.sounds.splice(index, 1);
        window[key].removeChild(elm);
      }
    }, id);
  }
function ( key ) { var self = this ; var sprite = self . _spriteMap [ key ] ; // Play the sprite sound and capture the ID. var id = self . sound . play ( sprite ) ; // Create a progress element and begin visually tracking it. var elm = document . createElement ( 'div' ) ; elm . className = 'progress' ; elm . id = id ; elm . dataset . sprite = sprite ; window [ key ] . appendChild ( elm ) ; self . sounds . push ( elm ) ; // When this sound is finished, remove the progress element. self . sound . once ( 'end' , function ( ) { var index = self . sounds . indexOf ( elm ) ; if ( index >= 0 ) { self . sounds . splice ( index , 1 ) ; window [ key ] . removeChild ( elm ) ; } } , id ) ; }
Play a sprite when clicked and track the progress.
@param  {String} key Key in the sprite map object.
Play a sprite when clicked and track the progress .