A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Fade In/Out Multiple sounds

  1. #1
    Junior Member
    Join Date
    Oct 2000
    Posts
    8

    Fade In/Out Multiple sounds

    I am loading multiple sounds using sound object. I want the sounds to fade in and out on pressing of different buttons. This is how the sounds are attached - to different instances of an empty movieclip on the stage:
    Code:
    bassoneloop = new Sound(bassonesound);
    basstwoloop = new Sound(basstwosound);
    clapsloop = new Sound(clapssound);
    drumsloop = new Sound(drumssound);
    rhodesloop = new Sound(rhodessound);
    tambloop = new Sound(tambsound);
    ukeeloop = new Sound(ukeesound);
    
    bassoneloop.attachSound("bassone");
    basstwoloop.attachSound("basstwo");
    clapsloop.attachSound("claps");
    drumsloop.attachSound("drums");
    rhodesloop.attachSound("rhodes");
    tambloop.attachSound("tamb");
    ukeeloop.attachSound("ukee");
    
    bassoneloop.setVolume(0);
    basstwoloop.setVolume(0);
    clapsloop.setVolume(0);
    drumsloop.setVolume(0);
    rhodesloop.setVolume(0);
    tambloop.setVolume(0);
    ukeeloop.setVolume(0);
    
    bassoneloop.start(0,300);
    basstwoloop.start(0,300);
    clapsloop.start(0,300);
    drumsloop.start(0,300);
    rhodesloop.start(0,300);
    tambloop.start(0,300);
    ukeeloop.start(0,300);
    And then I set up the function for fading in and fading out:

    Code:
    //function for sound fadein
    function fadeIn(soundname, loudness) {
    	v = soundname.getVolume();
    	onEnterFrame = function () {
    		if (v<=loudness) {
    			v = v+5;
    			soundname.setVolume(v);
    		}
    	};
    }
    function fadeOut(soundname) {
    	v = soundname.getVolume();
    	onEnterFrame = function () {
    		if (v>=0) {
    			v = v-5;
    			soundname.setVolume(v);
    		}
    	};
    }
    
    //fadeIn all tracks
    fadeIn(drumsloop,70);
    fadeIn(bassoneloop,100);
    fadeIn(basstwoloop,100);
    fadeIn(clapsloop,100);
    fadeIn(rhodesloop,100);
    fadeIn(tambloop,100);
    fadeIn(vocalloop,100);
    fadeIn(ukeeloop,100);
    When I go test the movie, only the last attached sound is affected. (ukeeloop), but not the others. To check that all the sounds are loaded. I tried the function singularly on each sound and they all work if the function is applied to one sound only. I also tried using simple setVolume() on each sound and they all work. But when I use the fadeIn function on all sounds as in the above, it stopped working. I've been scratching my head on this for 2 days already. Any idea?

  2. #2
    Senior Member EQFlash's Avatar
    Join Date
    Jun 2002
    Location
    where i'm at
    Posts
    2,735
    do you want the sounds to fade into each other or just individually fade in and out regardless which song is playing?
    If you don't think you're going to like the answer, then don't ask the question.

  3. #3
    Junior Member
    Join Date
    Oct 2000
    Posts
    8
    I want them to fade indiviually.
    Essentially all the sounds clips all start and play at the same time (they are different insturements for a complete song), but I want to be able to fade in and fade out some of them.

  4. #4
    Junior Member
    Join Date
    Oct 2000
    Posts
    8
    Btw, they are all sound loops. In the code above, what I'm trying to do is to fade them in in the beginning (which is not working right now) But I figure if I'm able to figure how to fade them in in the begining, I'd be able to apply the same code on a button.

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