View Full Version : Right click and middle mouse detection
MichaelxxOA
03-22-2005, 09:18 AM
Right Click and more...
--------------------------------------------------------------------------------
I'm not sure who all cares or if everyone but me knows this but you can actually detect the state of each mouse button, including the right and middle buttons... you do this with the ASnative(), this is a back door to all of the undocumented actionscript that flash has, so if you add the following code to the timeline
Code:
this.onEnterFrame = function() {
if (ASnative(800, 2)(1)) {
trace ("You have pressed or depressed the left mouse button");
}
}
this detects the left mouse... if you substitute the argument (1) with (2) you get the right mouse button so...
Code:
this.onEnterFrame = function() {
if (ASnative(800, 2)(2)) {
trace("You have pressed or depressed the right mouse button");
}
}
and if you put in a (4) you get the middle mouse or often the wheel button...
Code:
this.onEnterFrame = function() {
if (ASnative(800, 2)(4)) {
trace("You have pressed or depressed the middle mouse or wheel button");
}
}
I have tested these methods in both Flash MX and Flash MX 2004, i'm sure that if you have more buttons on your mouse and you keep trying to substitute the argument with different numbers you will get different results.. hope this helped.
-Michael
benwa02
05-09-2005, 08:20 PM
What do the (800,2) signify?
saw this a couple of times if you wana make me realy happy then tel me how to disable the menu "abouth macro...." because whit out this there is not a to big use to detect the right mouse click :(
(i am just sad that i can't make what i want ****ing menu)
MichaelxxOA
05-09-2005, 08:50 PM
there's gotta be a way to do it... I'm not sure though, i'll look into it.
-michael
i realy hope but i doubt :(
the only way coud by to embed it in a java aplet or .net
but that is to much stress and woud also blow it up
RQFlash
01-16-2006, 06:02 PM
MichaelxxOA, your code works great, with one exception. I'm trying to fire an event when the Middle Mouse button is pressed. With your code, it fires the event every time the frame is entered while the middle button is pressed. If you hold the button for a second or so, you get 20+ captures on the state of the mouse button. If you want to act on that button press only once, I don't see any easy way to do that. If there were some difference between the event that is triggered when the button is pressed verses the one that is triggered when the button is released, then I could use a semaphor of sorts, but that isn't the case either.
Anyone know of a way to do this?
spectre1989
01-16-2006, 07:47 PM
Well yeah just have a boolean that rings true once the middle mouse button is clicked, when the boolean is true do not call the event, when the boolean is false, then do call the event. Something like this (bit of pseudo code, but you get the idea):
IF (middlemousedown) {
IF (myboolean == false) {
myboolean = true;
callevent;
}
}ELSE{
myboolean = false;
}
RQFlash
01-16-2006, 07:54 PM
Thank you for the response. One of those cases where the simple solution evades you.
Thanks
spectre1989
01-16-2006, 08:04 PM
hehe tell me about it, I'm attempting to make a madness interactive style game at the moment, it's killing me i tell you!
does somebody know of a way to detect the middle button whit a LISTENER ?
movezig
05-23-2006, 02:56 PM
saw this a couple of times if you wana make me realy happy then tel me how to disable the menu "abouth macro...." because whit out this there is not a to big use to detect the right mouse click :(
(i am just sad that i can't make what i want ****ing menu)
He is absolutely right. WE HAVE GOT TO FIND OUT HOW TO DISABLE THAT STUPID MENU! im working on a commercial project where i have to disable the menu because customers could right click and exit out of the program, then get into the computer and mess it up if noones looking. (it's a swf by the way, not a projector). im so glad that i found the code above to work for detecting right click . it detects it, but the menu still pops up. i wish i could just throw a movie clip over top of the menu or something. everybody gives me "showmenu=false" etc. but this just shortens the options to two, one of which will load a new page etc.. Can anybody help?
the only working way i ever saw is
Hmmm not to sure but something along the line :
you need to overly it whit an opacel DIV in html
BUT then you wont get any mouse evnts at all in the SWF so you woud need to capture them in html and submit it to the SWF whit flahsvars
so no onpress rollout ... will work anylonger ! probably also all Key inputs
it's a night mare do to so and wrap all input to the SWF and make everithing whit hittest instead of rollout
btw disabling the right click menu VIOLATES MM lizense !!!
disable the menu because customers could right click and exit out of the program, then get into the computer and mess it up if noones looking.
but all this wont prevent me to simply clossing the browser :p
or presing ALT+CTRL+DEL and killing the task ;)
in your case it need to by a projector !!!
there are 3th pary projector tools wich (if i am not wrong) can disable the right click menu
then you also need to tween windows to not alowe CTRL+ALT+DEL
basicly the use of the taskmanager !
short cuts (including the StartMenu of window) truh wich you coud start programs like Explorer a comand promt ....
but i still coud close the projector whit the X in the corner
if the rest is properly secured i coudn't do any harm but the program woud need to by restarted !
it's mayby an option to make in to a scrensaver
never saw one or try it my self
but i woud expect that there is no X to close it ;)
where by i am not sure how windows woud handle it ona mouse move
woud it close it ? or is there a way to even if there is amouse move let the screensaver runing
...
..
.
so i will by definetly a nice pice of work to properly secure it !
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.