dcsimg
A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: Fade sound on scene??

  1. #1
    Expression...7 mullz's Avatar
    Join Date
    Jun 2000
    Location
    England
    Posts
    366

    Cool

    OK so here's the deal, I have 3 scenes

    Scene 1,

    s = new Sound();
    s.attachSound("music");
    s.start(0, 1);

    Scene 2,

    Music carries on from scene 1 in the library, I have
    a pause and the user clicks a button..things fade out, then have an action on the last frame which is;

    s.stop();

    "This works fine.."

    Question.. Can this be faded out instead of just cutting out??

    Cheers Ears..

  2. #2
    while (_global.Music.getVolume()>0) {
    starttime = getTimer();
    while (getTimer()<starttime+20) {
    }
    _global.Music.setVolume(_global.Music.getVolume()-1);
    }

    in the button should do the trick

    cheers

  3. #3
    Expression...7 mullz's Avatar
    Join Date
    Jun 2000
    Location
    England
    Posts
    366
    Cheers for that dude, still doesn't workthough...

    the code needs to be in the frame and not a button, would this make a difference?

    Cheers

  4. #4
    Senior Member
    Join Date
    Jul 2001
    Location
    Planet Earth
    Posts
    298

    This might work

    Code:
    // replace song with your sound's name
    function fadeSound(){
    	if (song.getVolume() > 0){
    	song.setVolume(song.getVolume() - 10);
    	trace(song.getVolume()); // used for debugging 
    	}
    	else {
    		clearInterval(counter);
    	}
    }
    place this on the frame where the fade should occur.

    Code:
    counter = setInterval(_root.fadeSound, 500);
    That code will create an Interval such that the function is run every half second (500 milliseconds) and the function reduces the volume of the sound by 10 each time it is called.

  5. #5
    Expression...7 mullz's Avatar
    Join Date
    Jun 2000
    Location
    England
    Posts
    366
    Where ddo you put the first bit of code?

    Is it in the button or on the frame?

    Cheers dude

  6. #6
    Senior Member
    Join Date
    Jul 2001
    Location
    Planet Earth
    Posts
    298
    First frame should do, right below where you started the sound.

    Here's what my first frame looks like:
    Code:
    song = new Sound();  // new sound object 
    song.attachSound("music"); //sound in the library export to action with name music
    song.start(); //get the groove going (play the sound)
    
    
    function fadeSound(){
    	if (song.getVolume() > 0){
    	song.setVolume(song.getVolume() - 10);
    	trace(song.getVolume());
    	}
    	else {
    		clearInterval(counter);
    	}
    }

  7. #7

    sound volume

    See now that turns down the volume on all my sounds. Why doesn't it distinguish between them? I've had this similar problem with sound in my other movies too.

  8. #8
    Expression...7 mullz's Avatar
    Join Date
    Jun 2000
    Location
    England
    Posts
    366
    I don't know why but its still not working I have the code in the first frame of scene 1, and the second bit of code in a frame after a button in scene 2,

    I take it you can cross scenes with this code??

    cheers people..

  9. #9
    Expression...7 mullz's Avatar
    Join Date
    Jun 2000
    Location
    England
    Posts
    366
    Ok so I have got it to work but it just suddenly decreases the volume to a whisper.. It doesn't fade out gradually..?

    Cheers

  10. #10
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Check this:

    How to Fade a Sound Object Up or Down

    Here:

    http://www.kennybellew.com/

  11. #11
    Expression...7 mullz's Avatar
    Join Date
    Jun 2000
    Location
    England
    Posts
    366
    cheers old man...

  12. #12
    Expression...7 mullz's Avatar
    Join Date
    Jun 2000
    Location
    England
    Posts
    366
    Im bringing this subject to the surface again...

    Im still having big problems with this sound doobry

    Any other ideas????

    Here's a doughnut for all those who helped before

    agghh have another one
    .

    www.expression7.com
    __________________

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center