Want to loop while mouse is pressed

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:

 
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

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

But will if i have to.

Thanks,
Reuben