Tuesday, May 09, 2006

Sound Objects

For sounds to not conflict with each other, they need to be assigned to movieclips - I think. This also works:

function newLevelMusic() {
var newLevel:Sound = new Sound();
newLevel.attachSound("newLevel");
newLevel.start();
}
newLevelMusic()

Here is a function that kind of works as a sound machine:

//sfxSpeaker
playSound = function (theID, theVolume, repeatTimes) {
voiceCounter++;
sfxSpeaker.createEmptyMovieClip("newVoiceMC"+voiceCounter, voiceCounter+10);
sfxSpeaker["newVoiceMC"+voiceCounter].theSound = new Sound(sfxSpeaker["newVoiceMC"+voiceCounter]);
sfxSpeaker["newVoiceMC"+voiceCounter].theSound.attachSound(theID);
sfxSpeaker["newVoiceMC"+voiceCounter].theSound.setVolume(theVolume);
sfxSpeaker["newVoiceMC"+voiceCounter].theSound.start(0, repeatTimes);
};

No comments: