Sorry I keep asking so many questions, but how do you make a sound fade in or out? A code, and maybe even a screenshot, would be appreciated. Thanks,
-Fyce
Printable View
Sorry I keep asking so many questions, but how do you make a sound fade in or out? A code, and maybe even a screenshot, would be appreciated. Thanks,
-Fyce
Well the basic volume control command is
my_sound.setVolume(level);
where 'level' is a number from 0 to 100 and
'my_sound' is the sound object used to play the sound.....
so usage will depend on how your sound is incorporated in your movie and fading in and out is achieved by altering the 'level' variable say in a loop.
hope this helps
mike
Wait, so the 'my_sound' part is where we put the file name? Like, 'song.mp3', or something? What do we put in the 'my_sound' part?Quote:
Originally Posted by indogo
-Fyce
Ok ..say for example you wanted to play a song in the same folder (streamed) you could use
mySound = new Sound(); //creates a new sound object
mySound.loadSound("song.mp3", true); //loads the file in streaming mode
mySound.start(); //plays it
so all control of the music is referenced by the 'mySound' part
eg mySound.stop(); would stop the music
'mySound' can be any name you choose and bear in mind flash 7 and later is case sensitive.
hope this helps....takes a little while to sink in
mike
I tried the first code, and it pops up an error message saying:Quote:
Originally Posted by indogo
"Line 1: expecting a , or )"
On the mySound = new Sound(); part, do I put a filename in between the (), such as /Music/song.mp3, or just the song.mp3 part, or what? If you could give me a screenshot, that would be awesome!
-Fyce
Mike, that is the most succinct and clear explanation I've seen. Or maybe I am finally getting my head around Actionscript enough to grasp it. If I ever start my KM wiki, that paragraph go in page one of Audio. Thanks.Quote:
Originally Posted by indogo
Fyce,Quote:
Originally Posted by Fyce
I just cut and pasted Mike's code into the first frame of a blank movie. I saved it into a folder that contained an mp3 that I had renamed as "song.mp3" to go with the code. Then I ran it in a browser and after a moment heard the sweet voice of Doris Day. Try cutting and pasting just this code part:
It otta woik. (Or put the name of your mp3 within the quotes in line 2.)Code:mySound = new Sound(); //creates a new sound object
mySound.loadSound("song.mp3", true); //loads the file in streaming mode
mySound.start(); //plays it
I'd say both are correct Jim :) Lookin good Mike :thumbsup:Quote:
Mike, that is the most succinct and clear explanation I've seen. Or maybe I am finally getting my head around Actionscript enough to grasp it.
mySound = new Sound();
just as is...check nothing extra has been picked up when copying...does happen..
and is the code where jim describes?..use the movie 'overview/actionscript displayed' to check...is the best place to look when using code.
This will also play other tunes as well as Doris Day....
mike
For sure. The Andrews Sisters, too. Not to mention Ella...Quote:
Originally Posted by indogo
Quote:
Originally Posted by Fyce
To fade in our out, you could put this into a movieclip . Then change the volume to 0 or 100 and change vol = vol - 1; to vol = vol =1; as needed for fade n or fade out
onClipEvent(load){
mySound = new Sound(); //creates a new sound object
mySound.loadSound("3.mp3", true); //loads the file in streaming mode
mySound.start(); //plays it
var vol;
vol = 100;
volume = vol;
mySound.setVolume(vol);
}
onClipEvent(enterFrame){
vol = vol - 1;
mySound.setVolume(vol);
if (vol >= 99) {
vol = 99;
}
else if (vol <= 0) {
vol = 0;
}
}
Nicely rounded off :)
Actionscript in bite sized chunks...thats what we serve in the koolmoves restaurant..
We now have all the ingredients...we now gaze at the oven in antici...pation.
mike