# Sound fade in once then play normal for 999 loops?

**URL:** <https://forum.kirupa.com/t/sound-fade-in-once-then-play-normal-for-999-loops/6863>\
**Category:** Uncategorized\
**Created:** [October 18, 2002, 8:26am UTC](https://forum.kirupa.com/t/sound-fade-in-once-then-play-normal-for-999-loops/6863 "2002-10-18T08:26:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sintax321](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@sintax321](https://forum.kirupa.com/u/sintax321)\
**Post date:** [October 18, 2002, 8:26am UTC](https://forum.kirupa.com/t/sound-fade-in-once-then-play-normal-for-999-loops/6863/1 "2002-10-18T08:26:01Z")

</div>

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?:-\

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 18, 2002, 10:45am UTC](https://forum.kirupa.com/t/sound-fade-in-once-then-play-normal-for-999-loops/6863/2 "2002-10-18T10:45:13Z")

</div>

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):

```php
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;
}
////////////////////////////////
//////////////////////////////////////////////
///////////////////////////////////////////////

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 18, 2002, 2:59pm UTC](https://forum.kirupa.com/t/sound-fade-in-once-then-play-normal-for-999-loops/6863/3 "2002-10-18T14:59:09Z")

</div>

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.🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 18, 2002, 3:12pm UTC](https://forum.kirupa.com/t/sound-fade-in-once-then-play-normal-for-999-loops/6863/4 "2002-10-18T15:12:07Z")

</div>

> \*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:

```php

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 18, 2002, 3:15pm UTC](https://forum.kirupa.com/t/sound-fade-in-once-then-play-normal-for-999-loops/6863/5 "2002-10-18T15:15:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 18, 2002, 3:18pm UTC](https://forum.kirupa.com/t/sound-fade-in-once-then-play-normal-for-999-loops/6863/6 "2002-10-18T15:18:10Z")

</div>

u r welcome:)
