View Full Version : Right click actions? [MX]
Scootman
June 12th, 2003, 11:36 AM
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?
Jubba
June 12th, 2003, 12:06 PM
no.
senocular
June 12th, 2003, 12:12 PM
http://proto.layer51.com/d.aspx?f=932
Scootman
June 12th, 2003, 01:39 PM
setInterval(function(){if(Mouse.rightMouseDown^(Mo use.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)
senocular
June 12th, 2003, 01:49 PM
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");
}
kode
June 12th, 2003, 01:50 PM
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;
;)
kode
June 12th, 2003, 01:51 PM
i demand you to delete your post, senocular!! :hair: :P ;)
Scootman
June 12th, 2003, 02:04 PM
wow, thats great... thanks a lot you guys...
heh there wouldnt by chance be any way to disable the right click menu eh?
senocular
June 12th, 2003, 02:07 PM
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.
Scootman
June 12th, 2003, 02:14 PM
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
senocular
June 12th, 2003, 02:38 PM
I often use something liek Shift+Click. Might be an alternative
Scootman
June 12th, 2003, 02:57 PM
hmm i think ill try that..
thanks again
uk_martin
July 1st, 2003, 11:19 AM
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,scro llbars=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
kode
July 2nd, 2003, 01:27 AM
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("javascript:openNewWindow('picture1.htm','Picture', 'height=480,width=777,toolbar=no,resizable=no,scro llbars=no');");
};
Mouse.addListener(myObj);
??
uk_martin
July 3rd, 2003, 04:16 AM
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
kode
July 3rd, 2003, 11:56 AM
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("javascript:openNewWindow('picture1.htm','Picture', 'height=480,width=777,toolbar=no,resizable=no,scro llbars=no');");
}
};
Mouse.addListener(myButton);
that should do... =)
Clown Staples
July 3rd, 2003, 08:45 PM
am i reading that right?? the key code is 0x000002 for a right mouse click??? how did whoever discovered that discover that?
Clown Staples
July 3rd, 2003, 08:52 PM
It works!! That is the most amazing thing I have ever seen.
uk_martin
July 4th, 2003, 07:18 AM
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
kode
July 4th, 2003, 05:55 PM
you put that code in the frame actions, not the button actions.
uk_martin
July 7th, 2003, 08:43 AM
Hi Kax
The script was cut and pasted into "Button1(panelBtn)" which is an invisible button which is in the "rotographic" MovieClip, in Scene1 of the movie.
Martin
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.