-
Grandfather to the stars
Fade external sound
I have background music playing from an external swf. Is it possible to fade this out by a button click?
-
FK'n_dog
something like this -
Code:
loadMovieNum("intro_song.swf",1);
ss = new Sound(_level1);
function fader(obj){
sv1++;
obj.setVolume(100-sv1);
trace("Volume - "+(100-sv1));
if(sv1>100){
clearInterval(fading);
}
};
btn.onRelease = function(){
fading = setInterval(fader,50,ss);
};
-
Grandfather to the stars
Thanks, but that still stops the sound suddenly, even if I play around with the number in '(fader,50,ss)'
-
FK'n_dog
how are you loading the external movie ?
how is the sound set up in that movie?
timeline ?
sound object ?
from - trace("Volume - "+(100-sv1));
what result do you get ? 99,98,97.... ??
-
Grandfather to the stars
Thanks for helping.
At the moment I'm loading the music.swf into a movie clip. The music.fla loads via the timeline.
With your code from trace I get:
Volume - NaN
which repeats ad infinitum. (Remembered that from school).
The music is in an intro, which fades into the site proper. I'd like the music to fade away, too, when the user clicks the skip intro button.
-
FK'n_dog
try using the instance name of the clip that the movie loads into -
Code:
clipInstanceName.loadMovie("intro_song.swf");
ss = new Sound(clipInstanceName);
var sv1:Number = 0; // declare the variable to avoid - NAN
function fader(obj){
trace(obj); // what is the output ?
sv1++;
obj.setVolume(100-sv1);
trace("Volume - "+(100-sv1)); // what is the output ?
if(sv1>100){
clearInterval(fading);
}
};
btn.onRelease = function(){
fading = setInterval(fader,50,ss);
};
-
Grandfather to the stars
Brilliant! That works fine.
But could I be really cheeky and ask if there's a way to speed up the fade? Altering the numeral in setInterval doesn't work.
Thanks again for your help.
-
FK'n_dog
the options are -
increase the interval speed
fading = setInterval(fader,10,ss); // 10 millisecond interval
or increase the fade rate -
sv1+=5; // increment by 5
-
Grandfather to the stars
Perfect, thank you so much. If I could email you a cake I would.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|