# Control sounds volume

**URL:** <https://forum.kirupa.com/t/control-sounds-volume/320354>\
**Category:** Uncategorized\
**Created:** [March 21, 2011, 3:02pm UTC](https://forum.kirupa.com/t/control-sounds-volume/320354 "2011-03-21T15:02:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flawsh](https://avatars.discourse-cdn.com/v4/letter/f/c0e974/32.png) [@Flawsh](https://forum.kirupa.com/u/Flawsh)\
**Post date:** [March 21, 2011, 3:02pm UTC](https://forum.kirupa.com/t/control-sounds-volume/320354/1 "2011-03-21T15:02:55Z")

</div>

hi,im trying to make a music/sound control and FX sounds control,so i have my FX volume level as a variable(FX\_vol) and also the Music/sound volume level as a diffrent variable(M\_vol),so i set them as sounds that i can use trough coding:

S1 = new Sound();  
S1.attachSound(“soundFX”);

S2 = new Sound();  
S2.attachSound(“soundM”);

and let the normal sound loop:

this.S2.start(0,99);

and i set that the sounds are allways getting their volume level(replace the old volume with the new one - for the player to set the music volume level and the sound FX volume level)  
so it looks like this:

function onEnterFrame()  
{  
S2.setVolume(M\_vol);  
}

and on that function i added an option of when the FX sound will play(when the player hits the ‘Z’ key)  
and it looks like this:

function onEnterFrame()  
{  
S2.setVolume(FX\_vol);  
S1.setVolume(M\_vol);

if(Key.isDown(90))  
{  
this.SW.start();  
}  
}

\*dont worry i added something to the code that you have to realease the Z key to press it again and make the sound again(so the problem is not here)

and when i run it both of the sounds(music and Fx) stays on the same volume and when i try to change the music volume level (in the running-i have some kind of a volume slider) and when i try to change the sound fx volume level they both stays the same,and dont change(not the sound fx and not the music…)

how can i fix that?
