class Rubynoid.SoundPlayer { private var _sounds = {}; function SoundPlayer() { } function includeSound( soundid ) { if (_sounds[soundid]) { return; } var newsoundset = []; for( var i=0; i<4; i++ ) { newsoundset[i] = new Sound(); newsoundset[i].attachSound(soundid); } newsoundset.cursor = 0; _sounds[soundid] = newsoundset; } function playSound( soundid ) { if (! _sounds[soundid]) { includeSound(soundid); } var soundset = _sounds[soundid]; soundset[soundset.cursor].start(); soundset.cursor++; if (soundset.cursor >= soundset.length) {soundset.cursor = 0;}; } }