// Sound.queueSounds Method v1.0 // by Jonas Galvez (jonasgalvez@uol.com.br) Sound.prototype.queueSounds = function() { if(arguments[0].length) var _sounds = arguments.shift(); else var _sounds = arguments; for(var i = 0; i < (_sounds.length-1); i++) { _sounds[i].onSoundComplete = function() { this.nextSound.start(); }; _sounds[i].nextSound = _sounds[i+1]; }; _sounds[_sounds.length-1].onSoundComplete = function() { this.nextSound.start(); }; _sounds[_sounds.length-1].nextSound = this; _sounds.shift().start(); }; // Usage Example // // _root.mySound1 = new Sound(); // _root.mySound1.attachSound("sound1"); // _root.mySound2 = new Sound(); // _root.mySound2.attachSound("sound2"); // _root.mySound3 = new Sound(); // _root.mySound3.attachSound("sound3"); // // _root.mySound1.start(); // _root.mySound1.onSoundComplete = function() { // this.queueSounds(_root.mySound2, _root.mySound3); // };