Hey, i know this has been asked before, but i couldnt find it anywhere. Is there any way to get an action when you right click your mouse in flash?
no.
setInterval(function(){if(Mouse.rightMouseDown^(Mouse.rightMouseDown=Key.isDown(2))) Mouse.rightMouseDown ? Mouse.broadcastMessage(“onRightMouseDown”) : Mouse.broadcastMessage(“onRightMouseUp”);},40);
usage
Mouse Events onRightMouseDown, onRightMouseUp:
event handlers for right mouse button clicks. Checks
for these clicks happen every 40 milliseconds.
- In order for these to be recognized, be sure to add your movieclip/object as a listener
of the mouse object: Mouse.addListener(myObject);
ok… so i put that in my frame in the main timeline… then i do that add listener thing… but how do i actually use it… (sorry ive never used listeners in flash before)
if you want to set the click for your current timeline, then use something like:
Mouse.addListener(this);
this.onRightMouseDown = function(){
trace("Right mouse button pressed");
}
this.onRightMouseUp = function(){
trace("Right mouse button released");
}
myObject.onRightMouseDown = callback;
myObject.onRightMouseUp = callback;
where callback can be an anonymous function:
myObject.onRightMouseDown = function() {
trace("right mouse is down");
};
or a named function:
function myFunction() {
trace("right mouse is down");
};
myObject.onRightMouseDown = myFunction;
i demand you to delete your post, senocular!! :hair:
wow, thats great… thanks a lot you guys…
heh there wouldnt by chance be any way to disable the right click menu eh?
nope, atleast not online. You can reduce its contents with the publish settings, but its not going away completely
if you are exporting to a projector, there are 3rd party tools that can disable the menu though. I believe screenweaver is one of them.
well thats pretty cool… i appreciate all the help… but i dont think its gonna work out for what i was trying to make…
im tryin to make movement pretty much like in strategy games… highlight, right click, they move there
i got it with a key press… i thought right click would be cool, but with the menu i dont think it will work out…
anyway heh if you wanna see what ive done so far here it is… http://www.freewebs.com/scottgilmore/selector.html you push the space bar to make them move to where the mouse is (i need to fix it so they wont overlap eachother
I often use something liek Shift+Click. Might be an alternative
hmm i think ill try that…
thanks again
In simple terms, for a total newbie here, if I want to open a pop-up window using a right click instead of a left click, how do I integrate the following javascript call with the stuff mentioned above?
getURL(“javascript:openNewWindow(‘picture1.htm’,‘Picture’,‘height=480,width=777,toolbar=no,resizable=no,scrollbars=no’)”);
Something simple would be appreciated, like paste this here & paste that there, please.
I’m getting my head around all this slowly, but my project can’t wait for my head :*(
Thanks
Martin
setInterval(function () {
if (Mouse.rightMouseDown ^ (Mouse.rightMouseDown=Key.isDown(2))) {
Mouse.rightMouseDown ? Mouse.broadcastMessage("onRightMouseDown") : Mouse.broadcastMessage("onRightMouseUp");
}
}, 40);
myObj = new Object();
myObj.onRightMouseDown = function() {
getURL("java****script:openNewWindow('picture1.htm','Picture','height=480,width=777,toolbar=no,resizable=no,scrollbars=no');");
};
Mouse.addListener(myObj);
??
This puzzles me…
To make this work with the right-click of a button, I would have expected the code to start with and event handler, like
" onRightMouseDown(…"
The code above seems to be either incomplete or I’m not putting it in the right place.
More help neded please
the code is not incomplete, you’re supposed to paste the it in the frame actions.
however, the code will be triggered whenever you right click over your movie. to make it work like an onPress handler, you could try this:
setInterval(function () {
if (Mouse.rightMouseDown ^ (Mouse.rightMouseDown=Key.isDown(2))) {
Mouse.rightMouseDown ? Mouse.broadcastMessage("onRightMouseDown") : Mouse.broadcastMessage("onRightMouseUp");
}
}, 40);
Button.prototype.hitTest = MovieClip.prototype.hitTest;
myButton.onRightMouseDown = function() {
if (this.hitTest(this._parent._xmouse, this._parent._ymouse, true)) {
getURL("java****script:openNewWindow('picture1****.htm','Picture','height=480,width=777,toolbar=no,resizable=no,scrollbars=no');");
}
};
Mouse.addListener(myButton);
that should do… =)
am i reading that right?? the key code is 0x000002 for a right mouse click??? how did whoever discovered that discover that?
It works!! That is the most amazing thing I have ever seen.
Hi Kax
Please excuse my ignorance, but I copied an pasted your script into the AS for my button, but I get the following error messages when testing the movie:
Symbol=rotographic, Layer=button, Frame=4: Line 13: Statement must appear within on handler
setInterval(function () {
Symbol=rotographic, Layer=button, Frame=4: Line 18: Statement must appear within on handler
Button.prototype.hitTest = MovieClip.prototype.hitTest;
Symbol=rotographic, Layer=button, Frame=4: Line 21: String literal was not properly terminated
getURL("javascript:openNewWindow(‘picture1. htm’,‘Picture’,'height=480,width=777,toolbar=no,re
Symbol=rotographic, Layer=button, Frame=4: Line 22: ‘)’ or ‘,’ expected
sizable=no,scrollbars=no’);");
Symbol=rotographic, Layer=button, Frame=4: Line 23: ‘;’ expected
}
Symbol=rotographic, Layer=button, Frame=4: Line 19: Statement must appear within on handler
myButton.onRightMouseDown = function() {
Symbol=rotographic, Layer=button, Frame=4: Line 25: Statement must appear within on handler
Mouse.addListener(myButton);
The intention was to share the button with the following script which enlarges / shrinks the thumbnail image on left clicks.
on (press) {
if (out) {
_parent.pressv=-2;
out=false;
} else {
_parent.pressv=2;
out=true;
}
}
So you can see what I want to do, left clicks enlarge and shrink the thumbnail size, right-clicks bring up a pop-up window with the full sized image.
What I need to have is the script which I can put in place of the existing script to achieve this goal.
Thanks for your help.
Martin
you put that code in the frame actions, not the button actions.