MouseDown Event

MouseDown Event

Post by Jaz Chan » Sun, 18 Jan 2009 01:49:04


Hi Guys,

Cant use the search box because it seems to spit up and error. Basically I
want to fire a method for as long as a button is held down and stop as soon as
the button is released. I've written a method which I thought would do the
trick but it doesn't seem to work and I cannot see why.

Can anyone please tell me why the following gets stuck in an inifinite loop;

private function scrollDown():void{
trace("Mouse Down");
while(isMouseDown){
//calendarBox.verticalScrollPosition += 20;
trace("down");
if(isMouseDown == false){
break;
}
}
isMouseDown = true;
}

private function mouseUpDetect():void{
trace("Mouse Up");
isMouseDown = false;
}

<mx:Button x="128" y="517.9" label="v" mouseDown="scrollDown()"
mouseUp="mouseUpDetect()"/>
 
 
 

MouseDown Event

Post by EWN-CM » Sun, 18 Jan 2009 23:59:13

PushkinAS is correct, in your function mouseDownDetect you set isMouseDown = true so once in the while loop you will always be there, since it never gets reset to false. Good Luck.

 
 
 

MouseDown Event

Post by ntsii » Mon, 19 Jan 2009 05:01:37

You will want to use setInterval or Timer, to break up the loop. google this you will find some examples, here is one:
http://www.yqcomputer.com/
 
 
 

MouseDown Event

Post by ntsii » Mon, 19 Jan 2009 05:01:45

You will want to use setInterval or Timer, to break up the loop. google this you will find some examples, here is one:
http://www.yqcomputer.com/