How to work with specific mouse buttons such as xbutton1 and xbuton2?
You can only access the left (or primary) mouse button in Flash. You can create custom context menus though that are accessed via right click.
Just saw that you have selected the AIR tag, so I guess you are targetting AIR. Then you'll be able to access all mouse buttons. See flash.events.MouseEvent for details, on which events are available.
To add an event listener for MouseEvents to an DisplayObject simply do something like this:
displayObject.addEventListener( MouseEvent:MOUSE_DOWN, myMouseDownHandler );
Where myMouseDownHandler
is an event handler function like this:
function myMouseDownHandler ( event:MouseEvent )
{
// do something
}
edit
As said in a comment, it's not possible for Flash (or actually any other program) to determine if an additional button on the mouse is pressed. The mouse driver is responsible for mapping those button clicks to special commands (such as opening a program etc), and you could even do fancy stuff like overwriting the right mouse click to something else and putting it on a completely different button (in which way that other button would report as "right click" in programs).
So no, you can't access additional mouse buttons in Flash.
If you programming Air, there are mousedown, rightMouseDown, and middleMouseDown events. If you're not programming air, you are indeed right, and there is only the one mouse down event.
Hmm, i've found interesting post here Same problem, and it seems that solution was found!
I used an AS2 swf and ASNative to register the mouse events and sent them to my AS3 swf over a LocalConnection
Can anybody say how to use this?