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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

possible to detect mouse button hold? 1

Status
Not open for further replies.

theotrain

Programmer
Mar 5, 2003
150
MX
does flash have a way of ascertaining that the mouse button is in the DOWN state, as seperate from detecting the instant it is pressed or released?

im making a custom scroll panel and i would like my arrow buttons to behave like browser arrows, if you hold them the window will continue to scroll.

the only thing i can think of is to begin scrolling on mouse press and wait for a release/rollout to stop. that scheme isnt 100% reliable though as it seems if a user moves his mouse very quickly out of the flash window sometimes rollouts and mouse releases are not detected. any better ideas?

thanks...
 
Flash has no "mouseDown" property but you don't need it. Following is a most simplistic example:

[tt]// AS2 main timeline
var scrollDirection:String;
mcUp.onPress = function():Void {
scrollDirection = "up";
};
mcUp.onRelease = mcUp.onReleaseOutside=function ():Void {
scrollDirection = null;
};
mcDown.onPress = function():Void {
scrollDirection = "down";
};
mcDown.onRelease = mcDown.onReleaseOutside=function ():Void {
scrollDirection = null;
};
this.onEnterFrame = function():Void {
switch (scrollDirection) {
case "up" :
mcX._y++;
break;
case "down" :
mcX._y--;
break;
}
};
stop();
//[/tt]

Kenneth Kawamoto
 
thanks kenneth. i actuallly implemented something using the same principle, only with much uglier code since i haven't wrapped my mind fully around AS2 and keeping my code in one place.

but i had the same idea of just using the mouse press to trigger an onEnterFrame function that would keep going until you released... and it works great.

i really need to start learning from other coders like yourself about writing cleaner code though, i have my button actions in my buttons and editing my mess is always a pain.

thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top