is it available mouse right click event in flash?

Dani AI

Generated

Right-click behavior in Flash depends on the player and ActionScript version. As shows, low-level/native tricks can detect button presses in some environments, but those calls are undocumented and not portable to browser SWFs. For reliable, production-safe handling use the supported APIs for the target runtime.

For ActionScript 3 (Flash Player 10+), Flash exposes right-click events. Enable the flag on the object that will receive the event and listen for the right-click event:

stage.rightClickEnabled = true;
stage.addEventListener(MouseEvent.RIGHT_CLICK, onRightClick);

function onRightClick(e:MouseEvent):void {
    trace("Right click at " + e.stageX + "," + e.stageY);
    // show custom context menu or handle action
}

For older players or AS2 where native right-click events are unavailable in-browser, capture the browser contextmenu via JavaScript and forward it to the SWF using ExternalInterface. Example pattern:

document.addEventListener('contextmenu', function(e){
  e.preventDefault();
  var swf = document.getElementById('mySWF');
  if (swf && swf.handleRightClick) swf.handleRightClick(e.clientX, e.clientY);
}, false);

Expose a callback from Flash with ExternalInterface.addCallback to receive that call.

Notes and cautions: test in the exact deployment (browser, projector, AIR) because behavior differs. Right-click is not applicable on touch devices. Avoid undocumented hacks for public web content; prefer AS3/ExternalInterface approaches for cross-browser reliability.

This should solve your problem

this.onEnterFrame = function() 
{
    if (ASnative(800, 2)(1)) 
    {
        trace ("You have pressed or depressed the left mouse button");
    }
}

If you swap (1) for (2) you get right mouse press and if you swap it for (4) you can take care of middle mouse button

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.