Search code examples
actionscript-3contextmenuflashswfobject

disabling context menu and mouse in Flash


This should be pretty straight forward.

this should do the trick

stage.removeEventListener(MouseEvent.RIGHT_CLICK, function(e:MouseEvent):void{});
Mouse.hide();

and when I run it in the standalone player it works.

However when I run it in a browser, the right-click menu shows up again. I've tried setting the param wmode="opaque", which removes context menu (independent of the code), but shows the mouse despite the css setting: cursor: none;

is there a another listener that calls the context menu that can be disabled?


Solution

  • To disable the context menu ( and the right click ), you can use MouseEvent.RIGHT_CLICK and / or MouseEvent.CONTEXT_MENU ( available from Flash Player 11.2 and up ) :

    stage.addEventListener(MouseEvent.RIGHT_CLICK, function(e:MouseEvent):void {});
    stage.addEventListener(MouseEvent.CONTEXT_MENU, function(e:MouseEvent):void {});
    
    Mouse.hide();
    

    Hope that can help.