# soundObject: Setting Volume

**URL:** https://forum.kirupa.com/t/soundobject-setting-volume/96129
**Category:** Uncategorized
**Created:** [December 5, 2003, 4:32am UTC](https://forum.kirupa.com/t/soundobject-setting-volume/96129 "2003-12-05T04:32:31Z")
**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 5, 2003, 4:32am UTC](https://forum.kirupa.com/t/soundobject-setting-volume/96129/1 "2003-12-05T04:32:31Z")

</div>

I have three frames in my main timeline. The first contains the preloader, the second is the entrance animation and the third is a menu loop. In the second frame (entrance animation), I’ve place this script on the main timeline in an “actions” layer:

backgroundAudio = new Sound();  
backgroundAudio.attachSound(“movieAudio”);  
audioVolume=70;  
backgroundAudio.setVolume(audioVolume);  
backgroundAudio.start(0, 99999);

In the third frame of the main timeline (menu loop), I have controls for the audio (ie. stop, play, volume, etc…) On the volume down button I have this script:

on (release) {  
audioVolume=(audioVolume-5);  
if (audioVolume\<5) {  
audioVolume = 1;  
trace(audioVolume);  
\_root.backgroundAudio.setVolume(audioVolume);  
\_root.gotoAndStop(“loop”);  
} else {  
trace(audioVolume);  
\_root.backgroundAudio.setVolume(audioVolume);  
}  
}

The problem is, the first time I hit either the volume up or down buttons, it acts as though the initial volume is 0. In other words, the value I set for “audioVolume” (70), in the second frame, loses it properties when a button is pressed. It does start playing at 70 though if untouched, and after a button is pressed and it resets to 0, then all buttons function properly, but the first press destroys everything. How do I combat this?

Thanks for your time and help.
