# Help with code for button

**URL:** <https://forum.kirupa.com/t/help-with-code-for-button/176981>\
**Category:** flash\
**Created:** [January 28, 2006, 8:02pm UTC](https://forum.kirupa.com/t/help-with-code-for-button/176981 "2006-01-28T20:02:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Terry\_elekes](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@Terry\_elekes](https://forum.kirupa.com/u/Terry_elekes)\
**Post date:** [January 28, 2006, 8:02pm UTC](https://forum.kirupa.com/t/help-with-code-for-button/176981/1 "2006-01-28T20:02:31Z")

</div>

I have a button that does three things when you release on it. See code below;  
mySpeed = 0;  
drive = function(){  
//speed text  
Speed\_txt = mySpeed+" kph";  
mySound = new Sound();  
mySound.attachSound(“bike”);  
};  
speedUp\_btn.onRelease = function() {  
mySpeed += 5;  
mySound.start();  
mySound.setVolume(mySpeed);  
};  
speeddown\_btn.onRelease = function(){  
mySpeed -= 5;  
mySound.setVolume(mySpeed);  
};  
\_root.onEnterFrame = drive;

my question is that on the first release i want mySound to start and also set the volume. I want the volume to increase as mySpeed increases. But when I release a secound or third time to increase mySpeed it start mySound again. How could I fix this so mySound only starts once.
