# Volume control (using setVolume)

**URL:** <https://forum.kirupa.com/t/volume-control-using-setvolume/36765>\
**Category:** flash\
**Created:** [December 1, 2003, 7:04pm UTC](https://forum.kirupa.com/t/volume-control-using-setvolume/36765 "2003-12-01T19:04:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lrm](https://avatars.discourse-cdn.com/v4/letter/l/a5b964/32.png) [@lrm](https://forum.kirupa.com/u/lrm)\
**Post date:** [December 1, 2003, 7:04pm UTC](https://forum.kirupa.com/t/volume-control-using-setvolume/36765/1 "2003-12-01T19:04:03Z")

</div>

I have this script placed at the root level:

backgroundAudio=new Sound();  
backgroundAudio.attachSound(“movieAudio”);  
backgroundAudioVolume=40;  
\_root.backgroundAudio.setVolume(backgroundAudioVolume);  
\_root.backgroundAudio.start(0,99999);

and this script placed on a volume up button:

on (release) {  
backgroundAudioVolume++;  
\_root.backgroundAudio.setVolume(backgroundAudioVolume);  
}

It works, but there’s one problem, when the volume up button is released and the volume increases by one unit, it does so from the beginning, resetting the backgroundAudioVolume to 0 and then increasing. How can I avoid this?
