# Want to loop while mouse is pressed

**URL:** <https://forum.kirupa.com/t/want-to-loop-while-mouse-is-pressed/232481>\
**Category:** flash\
**Created:** [July 14, 2007, 8:33am UTC](https://forum.kirupa.com/t/want-to-loop-while-mouse-is-pressed/232481 "2007-07-14T08:33:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dr\_Warm](https://avatars.discourse-cdn.com/v4/letter/d/4da419/32.png) [@Dr\_Warm](https://forum.kirupa.com/u/Dr_Warm)\
**Post date:** [July 14, 2007, 8:33am UTC](https://forum.kirupa.com/t/want-to-loop-while-mouse-is-pressed/232481/1 "2007-07-14T08:33:50Z")

</div>

Ok i keep crashing flash, and I can’t figure out a way to do it without.

Basically when the mouse is pressed, I want it to enter into a loop, and keep checking whether the mouse is moving left or right and then do some stuff, so this is what I tried:

```auto
 
this.MouseListener.onMouseDown = function() {
// while mouse is still depressed
  while(Key.isDown(1)){
        // do some stuff
  }
}

```

Because I want it to keep doing the stuff until the mouse is released. Whats the solution? Or any other suggestions? I don’t really want to do

```auto
 
onClipEvent(EnterFrame){
if(Key.isDown(1)){
// do the stuff
}
}

```

But will if i have to.

Thanks,  
Reuben
