function Sound(src){ //sound effect class //builds a sound effect based on a url //may need both ogg and mp3. this.snd = document.createElement("audio"); this.snd.src = src; //preload sounds if possible (won't work on IOS) this.snd.setAttribute("preload", "auto"); //hide controls for now this.snd.setAttribute("controls", "none"); this.snd.style.display = "none"; //attach to document so controls will show when needed document.body.appendChild(this.snd); this.play = function(){ this.snd.play(); } // end play function this.showControls = function(){ //generally not needed. //crude hack for IOS this.snd.setAttribute("controls", "controls"); this.snd.style.display = "block"; } // end showControls } // end sound class def