Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

detecting mouse still down over a button

Status
Not open for further replies.

wilcdr

Programmer
Jan 4, 2001
19
CA
Hi all,

Is there a way to keep executing some script while a mouse button is held down on top of a button? If you put in a on (press) event it will only do it once, but I want whatever is in the on (press) action of the button to keep executing while I have the mouse button still down.

Thanks!

Willy
 
What is the script you want repeated while the mouse button is held down?
mywink.gif
ldnewbie
 
I want to do something like this:

I have one object on the stage I want to move around, and I have four arrows on the screen to control it (and no, I can't use the keyboard for this one) to go up, down, left and right. Right now I have it so that you have to keep clicking one button to, say, keep moving the object to the left. I want to make it so that it moves to the left continuously while I hold down the left arrow button.

Thanks!

Willy
 
You can set up a variable that tells a script if the button is being pressed. For instance on a button to send an object on the screen to the left add this to the button..

on (press) {
_root.leftPressed = true;
}
on (release) {
_root.leftPressed = false;
}


and add this as a clip event to your movieClip...

onClipEvent (enterFrame) {
if (_root.leftPressed) {
_x--;
}
}


You can cut and paste from this to create move right, up and down behaviours.


 
Ah... thanks for the reply. So there is no mouseStillDown property of something I can check against, eh?

Willy
 
I also heard Flash 6 would come up bundled with every movie everybody ever imagined! Imagine! Nothing to fight against and no more search for workarounds! How boring will that be?
mywink.gif
ldnewbie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top