;

PDA

Click to See Complete Forum and Search --> : Fading In and Out


Fyce
08-13-2006, 10:02 PM
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

indogo
08-13-2006, 10:54 PM
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

Fyce
08-13-2006, 11:00 PM
'my_sound' is the sound object used to play the sound.....

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?

-Fyce

indogo
08-13-2006, 11:17 PM
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

Fyce
08-13-2006, 11:41 PM
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:

"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

jimventola
08-14-2006, 01:41 AM
hope this helps....takes a little while to sink in
mike

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.

jimventola
08-14-2006, 01:54 AM
I tried the first code, and it pops up an error message saying:

"Line 1: expecting a , or )"



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:

mySound = new Sound(); //creates a new sound object
mySound.loadSound("song.mp3", true); //loads the file in streaming mode
mySound.start(); //plays it

It otta woik. (Or put the name of your mp3 within the quotes in line 2.)

Chris_Seahorn
08-14-2006, 01:54 AM
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.

I'd say both are correct Jim :) Lookin good Mike :thumbsup:

indogo
08-14-2006, 08:27 AM
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

jimventola
08-14-2006, 06:57 PM
mySound = new Sound();
This will also play other tunes as well as Doris Day....
mike

For sure. The Andrews Sisters, too. Not to mention Ella...

tmoore935
08-14-2006, 09:48 PM
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


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;
}
}

indogo
08-14-2006, 10:11 PM
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