Thursday, July 12, 2007

Sound Object

///// CREATE NEW SOUND OBJECT ///////////
mySong = new Sound();

///// TELL SOUND WHAT TO DO ONCE LOADED ////
mySong.onLoad = function(success){
if(success){
mySong.start(0,1);
}else{
trace("Something bad happened");
}
}

//// GET THE SONG TO LOAD/PLAY //////////////
mySong.loadSound(song.mpg,false); // song you want, if the song is streaming

//// this will happen when the song is done playing ////
mySong.onSoundComplete = function(){
glow_mc._visible = false;
stopIt = true;
}

///// set the volume //////////////////
mySong.setVolume(100); // 100 is where you're setting it to
currentVolume = 5; // it could be a variable
maxVolume = 100;

// this is how you would fade in a song
movieclip_mc.onEnterFrame = function(){
if(currentVolume < maxVolume){
currentVolume += .6; // constantly increments volume by .6
mySong.setVolume(currentVolume);
}else{
delete(this.onEnterFrame); // delete brain after you're done
}
}

No comments: