morning all!
need some help on something here if possible so am hoping that someone can tell me how to do the following.
I have a number of mc's on my stage that can be clicked and dragged around - I want each mc to play one of four random sounds when clicked and dragged - but then I want the sound that is playing to fade out when the mouse is released. I have got it working with the stopallsounds function - but I would like the sounds to fade rather than stopping abruptly.
here is my code
Code:
//create an array to hold all the sounds
var sound_explosions_array:Array = Array();
//create a sound object
var explosion01_snd:Sound = new Sound();
//attach sound from library
explosion01_snd.attachSound("explosion01");
//add sound to array
sound_explosions_array.push(explosion01_snd);
var explosion02_snd:Sound = new Sound();
explosion02_snd.attachSound("explosion02");
sound_explosions_array.push(explosion02_snd);
var explosion03_snd:Sound = new Sound();
explosion03_snd.attachSound("explosion03");
sound_explosions_array.push(explosion03_snd);
var explosion04_snd:Sound = new Sound();
explosion04_snd.attachSound("explosion04");
sound_explosions_array.push(explosion04_snd);
//play random explosion
function playExplosion():Void{
//get random number based on sound array length
var randomNum:Number = random(sound_explosions_array.length);
//create a temporary sound object
var random_sound:Sound = sound_explosions_array[randomNum];
//tell temporary sound object to play
random_sound.start();
//trace
currentSound_txt = "Playing Sound "+randomNum;
}
//make container_mc a button, play explosion sound on click
container_mc.onPress = function(){
playExplosion();
}
container_mc.onRelease = function(){
StopAllSounds();
}
i guess this is the relevant line to edit
Code:
//make container_mc a button, play explosion sound on click
container_mc.onPress = function(){
playExplosion();
}
container_mc.onRelease = function(){
Stopallsounds();
}
but how do i write that last line to make it fade??
Anyone know? I have found a few bits n' bobs on the net - but they all seem to be for transitions of one sound to another - I don't need it to be quite so sophisticated, just a case of release mouse - sound fades.
Anyone put me right on this please?