Sound fade in once then play normal for 999 loops?

I’m loading my music in with external SWF’s. I have one swf loading in by deafult at the start. I wan’t the sound to fade in once and then loop normaly until the user changes the track(or turns off the music). If I put a fade in effet on the sound it fades in every time the loop starts over. I tried playing the sound once with a fade in then on the last frame playing the music without the fade and looping it 999 times with a stop action over it but the track started to over lap for some reason. Any ideas on a simple way to do this?:-\

Hi,

U should use the sound object so u can control the volume of any playing sound and by controlling the volume u can fade them in and out or blend them as u whish.
somethign in the lines of (this is very, very rough but it gives u an idea):

if (!track1Loaded) {
	loadMovieNum("track1.swf", 1);
	// I'm  assuming u load ur sound swf's like this
	track1Loaded = 1;
}
//check that the swf's loaded, if it has create a sound object and set its volume to 0
if (_level1.getBytesLoaded()>0 && _level1.getBytesLoaded()>=_level1.getBytesTotal()) {
	sound1 = new Sound();
	sound1.attachSound(_level1.linkageIdOfTrack1);
	sound1.start(0, 999);
	sound1.setVolume(vol);
}
if (vol<100 ) {  
// 100 is the loudest 
	for (var i = 0; i<100; i++) {
		vol += 1;
	}
} else {
	vol=100;
}
////////////////////////////////
//////////////////////////////////////////////
///////////////////////////////////////////////

Will a script like that only affect the sound object once because if it does thats exactly what I need. Also if I’m loading my sound into a MC instead of a layer do I check that MC’S (_root.sc.getBytesLoaded) root path instead of checking a layer(_level1.getBytesLoaded)?

I just started MX and I’ve only got into heavy actionscripting in the last 2 months so I didn’t know about this sound object. Thanks for showing me something new.:slight_smile:

*Originally posted by sintax321 *
**Will a script like that only affect the sound object once because if it does thats exactly what I need. Also if I’m loading my sound into a MC instead of a layer do I check that MC’S (_root.sc.getBytesLoaded) root path instead of checking a layer(_level1.getBytesLoaded)?
**

yes , it will . BTW The re’s an extra for loop that’s not need at all (don’t know what was I thinking) in the last bit:


if (vol<100 ) {  
// 100 is the loudest 
   // for (var i = 0; i<100; i++) { NOT NEEDED!!!!!!!!!!!!!!
        vol += 1;
  //  }
} else {
    vol=100;
}

Yes, u r right about the path too (although I tend not to use ‘_root’ at all as it may f*** things up in complex projects. It’s better to use relative paths. But that’s another topic altogether)

Cheers

Bye

Thanks again I’ll see what I can do:)

u r welcome:)