|
Example of how to fade sound in
|
Follows is an example of how to fade sound in. We'll be using the sound object and placing everything inside an MC. Basically the way this works is, we set up the sound object in frame 1 of our sound MC, then we use the set volume method of the sound object to gradually increase the sound: 1) Insert/New Symbol/Movie. You should now be in the MC's editing mode. 2) Frame 1 add the script: stop ();
s = new Sound(this);
s.attachSound("mySound");
s.setVolume(0 );
//frame5: s.setVolume(10 ); //frame10: s.setVolume(20 ); //frame15: s.setVolume(30 ); //frame20: s.setVolume(40 ); //frame25: s.setVolume(50 ); //frame30: s.setVolume(60 ); //frame35: s.setVolume(70 ); //frame40: s.setVolume(80 ); //frame45: s.setVolume(90 ); //frame50: s.setVolume(100 ); //Start button:
on (release) {
s.start(0,10);
play ();
}
//Stop button:
on (release) {
s.stop();
gotoAndStop (1);
}
Posted by: No name | website http:// |
//**********************************************
// create Sound obj and set volume at 0
//**********************************************
sndObj = new Sound();
sndObj.attachSound("loop");
sndObj.setVolume(0);
//**********************************************
// function to fade in the sound
//**********************************************
function fadeSnd(speed) {
this.onEnterFrame = function() {
vol += speed;
if (sndObj.getVolume() == 100) {
//trace("sound at max!");
delete this.onEnterFrame;
} else {
sndObj.setVolume(vol);
// show the fade
display = sndObj.getVolume();
}
};
}
//**********************************************
// button to activate snd and fadeSnd function
//**********************************************
sndBtnOn_mc.onPress = function() {
sndObj.start(0, 9999);
fadeSnd(1);
};
//**********************************************
Posted by: Martin Bjeld | website http://www.coolwebsites.dk |
//Place the following in frame one:
var intervalID;
//**********************************************
// Set max and min volume levels.
//**********************************************
maxlevel = 100;
minlevel = 20;
//**********************************************
// Set Fade speed
// The higher the number, the longer the fade.
//**********************************************
fadespeed = 20;
//**********************************************
// create Sound object and attach a linked sound
//**********************************************
s = new Sound();
s.attachSound("loop");
function fadeup() {
clearInterval(intervalID);
intervalID = setInterval( upOne, fadespeed);
}
function fadedown() {
clearInterval(intervalID);
intervalID = setInterval( downOne, fadespeed);
}
// BUMP VOLUME UP
function upOne(){
varSnd=s.getVolume();
if (varSnd < maxlevel){
s.setVolume(varSnd+1);
}else{
clearInterval(intervalID);
}
updateAfterEvent();
}
// BUMP VOLUME DOWN
function downOne(){
varSnd=s.getVolume();
if (varSnd > minlevel){
s.setVolume(varSnd-1);
}else{
clearInterval(intervalID);
}
updateAfterEvent();
}
//**********************************************
// Start your Sound
//**********************************************
s.start(0,100);
//////////////////////////////////////////////////////////////
2) To call the functions, use the following code:
fadedown();
//or
fadeup();
Posted by: Michael Tapson | website http://www.tapsonic.com |
|
Method 1 was time consuming, you have to make all those frame and placing s.setVolume(10);, s.setVolume(20);, etc. So I decided to make it fade in using actionscripts. Lets get started! 1) Insert/New Symbol/Movie. You should now be in the MC's editing mode. 2) Frame 1 add the script: s = new Sound(this);
s.attachSound("mySound");
s.setVolume(0);
s.start(0, 9999);
s.setVolume(s.getVolume += 1) if(s.getVolume == 100) {
gotoAndStop(4);
} else {
gotoAndPlay(2);
}
Posted by: Minh Luu | website http://bio.barrierx.com/ |
|
1) Insert/New Symbol/Movie 2) In Frame 1, add the script:
vol = _root.s.getVolume();
_root.s.setVolume(vol-1);
if (_root.s.getVolume() == 0) {
_root.s.stop();
}gotoAndPlay (1); Posted by: Mikke Schirén | website http://www.fororten.com |

