# Need help fast with audio fading

**URL:** <https://forum.kirupa.com/t/need-help-fast-with-audio-fading/68639>\
**Category:** Uncategorized\
**Created:** [October 27, 2004, 3:35pm UTC](https://forum.kirupa.com/t/need-help-fast-with-audio-fading/68639 "2004-10-27T15:35:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![defcap](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@defcap](https://forum.kirupa.com/u/defcap)\
**Post date:** [October 27, 2004, 3:35pm UTC](https://forum.kirupa.com/t/need-help-fast-with-audio-fading/68639/1 "2004-10-27T15:35:31Z")

</div>

i need to have two audio file’s volume fade from 0 to 100 along the x axis, so that when one fades in, the other fades out, and reversed. heres to code i have now (that doesnt work):

> 

mySound = new Sound();  
mySound.attachSound(“music”);  
mySound.start();

mySound2 = new Sound();  
mySound2.attachSound(“music2”);  
mySound2.start();

onEnterFrame = function(){  
var volume = (\_root.\_xmouse / Stage.width) \* 100;  
var volume2 = (100 - volume);

mySound.setVolume(volume);  
mySound2.setVolume(volume2);  
}

this isnt working (and it isnt identifier names), if someone can either fix that, or make a new script that does what i want that would be greatly appreciated. im totally stumped.
