Skip to main content
Inspiring
June 4, 2008
Question

Fade in and fade out audio with as

  • June 4, 2008
  • 8 replies
  • 507 views
hi 🙂 i load my sound like this on frame 1

mysound = new Sound();
mysound.loadSound("1.mp3", true);
mysound.setVolume(100);
mysound.onSoundComplete = function ()
{
mysound.start(0);
};
stop ();
but on frame 2 i want to fade out mysound with as(set folum on 0 with fade out) and on frame 7 to fade in (to set volume again on 100 with fade in)

can some one helps
This topic has been closed for replies.

8 replies

Inspiring
June 8, 2008
it still doesnot works :(
Inspiring
June 5, 2008
hey - replace the function with this one, and let me know what it spits out.

function fadeSound(num) {
trace("I'm trying to work!");
mysounds.setVolume((mysound.getVolume()-num)/4);
if (mysound.getVolume<1) {
clearInterval(superAwesomeInterval);
}
Inspiring
June 5, 2008
no iget no errors, :) thanks for help :) waiting for u :)
Inspiring
June 5, 2008
multi-frame!! gah - okay, I'll look at it when I get some time. In the mean-time, what are the errors that pop-up, or is there nothing?
Inspiring
June 5, 2008
ok on firs fdrame i have this

mysound = new Sound();
mysound.loadSound("1.mp3", true);
mysound.setVolume(100);
mysound.onSoundComplete = function ()
{
mysound.start(0);
};
stop ();

on second i paste this

function fadeSound(num) {
mysounds.setVolume((mysound.getVolume()-num)/4);
if (mysound.getVolume<1) {
clearInterval(superAwesomeInterval);
}
}

on frame 15 where i want to fade out audio i paste this

superAwesomeInterval = setInterval(fadeSound, 5, 0);


but it doesnot works :( any idea

Inspiring
June 4, 2008
whoops!! forgot the most important line of that function ... what else did I forget ;) ???

function fadeSound(num) {
mysounds.setVolume((mysound.getVolume() - num)/4);
if (mysound.getVolume < 1) {
clearInterval(superAwesomeInterval);
}
}
Inspiring
June 4, 2008
ok thanks i will test it and post then the results ,anyway thanks thanks:)
Inspiring
June 4, 2008
//this will fade the sound to 0 from whatever it is...
superAwesomeInterval = setInterval(fadeSound, 5, 0);

//this will fade the sound to 100 from whatever it is...
superAwesomeInterval = setInterval(fadeSound, 5, 100);

function fadeSound(num) {
(mysound.getVolume() - num)/4
if (mysound.getVolume < 1) {
clearInterval(superAwesomeInterval);
}
}

make sense? I think that would work, but maybe not - try it out and let me know.