# \[F8\] how can you stop a function?

**URL:** <https://forum.kirupa.com/t/f8-how-can-you-stop-a-function/282178>\
**Category:** flash\
**Created:** [February 18, 2009, 5:21pm UTC](https://forum.kirupa.com/t/f8-how-can-you-stop-a-function/282178 "2009-02-18T17:21:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![capdetrons](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@capdetrons](https://forum.kirupa.com/u/capdetrons)\
**Post date:** [February 18, 2009, 5:21pm UTC](https://forum.kirupa.com/t/f8-how-can-you-stop-a-function/282178/1 "2009-02-18T17:21:21Z")

</div>

I have a button that triggers the function addToBet and doesn’t allow the textfileds to show any larger number but I can’t stop the clips with the coins I’m trying to attach. The function showBet keeps running.

any idea of how to achieve this? I have tried using loops but I am really confused.

bet = 1;

function addToBet() {  
bet ++;  
if (bet\>5) {  
bet = 5;  
return;  
}  
showBet();  
}

function addToBet() {  
displayBet = bet;  
this.attachMovie(“contCoin”, “contBet”, this.getNextHighestDepth(), {\_x:150, \_y:400});  
contBet.attachMovie(“coin”, “coin”, this.getNextHighestDepth(), {\_x:Math.random()\*50-50, \_y:Math.random()\*50-50});  
}
