# Hold down button counter

**URL:** https://forum.kirupa.com/t/hold-down-button-counter/99605
**Category:** Uncategorized
**Created:** [January 20, 2004, 2:59pm UTC](https://forum.kirupa.com/t/hold-down-button-counter/99605 "2004-01-20T14:59:06Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Sigfa](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@Sigfa](https://forum.kirupa.com/u/Sigfa)
#### Post date: [January 20, 2004, 2:59pm UTC](https://forum.kirupa.com/t/hold-down-button-counter/99605/1 "2004-01-20T14:59:06Z")

</div>

Ok, i have this problem- i have a button and a dinamic text field w/ an input variable called “myLuck”. if the user clicks the mouse and holds it down the “myLuck” increses every 0.3 seconds by 1. also there is a variable called “left” which has a value of, say, 25. the user cannot use up more then the “left” is currently holding. I can’t actualy come up with a reasonable AS, but this is where i am:  
[AS]on(press){  
while(true){  
Mouse.addListener(this.onMouseUp = function() {  
break  
}  
if(left \> 0){  
left = left - 1  
myLuck = myLuck + 1  
}  
}  
}[/AS]

help anyone?
