SOLVED: Right Click in AS3

August 19th, 2007

Eureka,

A day or two ago polyGeek has revived an old and challenging idea that one could make use of custom right-click functionality in Flash (AS3 + Javascript).

Why would anyone want to do this? Well, there are several very important reasons:

1) Games – the power of AS3 has brought Flash to the world of digital entertainment. At last it is possible to focus on the idea of your game rather than on how to improve the laggy experience. One thing that is still missing – right click functionality. We had this forever in desktop games, now it is time to let your casual RTS, RPG and FPS creations conquer the web.

2) User Experience – 2 buttons are better than 1. Every experimentalist’s dream is to be able to have more input options, not just one button. I can bet someone would soon create a stunning interface using this new functionality and we would see that on no less than FWA.

3) RIA – Rich Internet Applications. My clients are often asking if it is possible to remove embeded Flash Player menus from their applications and replace them with their company’s branding stuff.

***

AND THE ANSWER IS – YES! It is now possible to use custom right-click functionality in Flash and even Flex.

After long hours of searching through Microsoft’s documentation I came up with a universal solution that works nicely at least on 3 major browsers – Firefox 2, IE 7 and Safari. (IE6 has not been tested but I can bet it works OK).

***

Here you can see the * DEMO of right click * functionality (click the grey area to draw transparent dots)

Javascript source code looks like this:

[javascript]
/**
*
* Copyright 2007
*
* Paulius Uza
* http://www.uza.lt
*
* Dan Florio
* http://www.polygeek.com
*
* Project website:
* http://code.google.com/p/custom-context-menu/
*
* –
* RightClick for Flash Player.
* Version 0.6.2
*
*/

var RightClick = {
/**
* Constructor
*/
init: function () {
this.FlashObjectID = “customRightClick”;
this.FlashContainerID = “flashcontent”;
this.Cache = this.FlashObjectID;
if(window.addEventListener){
window.addEventListener(“mousedown”, this.onGeckoMouse(), true);
} else {
document.getElementById(this.FlashContainerID).onmouseup = function() { document.getElementById(RightClick.FlashContainerID).releaseCapture(); }
document.oncontextmenu = function(){ if(window.event.srcElement.id == RightClick.FlashObjectID) { return false; } else { RightClick.Cache = “nan”; }}
document.getElementById(this.FlashContainerID).onmousedown = RightClick.onIEMouse;
}
},
/**
* GECKO / WEBKIT event overkill
* @param {Object} eventObject
*/
killEvents: function(eventObject) {
if(eventObject) {
if (eventObject.stopPropagation) eventObject.stopPropagation();
if (eventObject.preventDefault) eventObject.preventDefault();
if (eventObject.preventCapture) eventObject.preventCapture();
if (eventObject.preventBubble) eventObject.preventBubble();
}
},
/**
* GECKO / WEBKIT call right click
* @param {Object} ev
*/
onGeckoMouse: function(ev) {
return function(ev) {
if (ev.button != 0) {
RightClick.killEvents(ev);
if(ev.target.id == RightClick.FlashObjectID && RightClick.Cache == RightClick.FlashObjectID) {
RightClick.call();
}
RightClick.Cache = ev.target.id;
}
}
},
/**
* IE call right click
* @param {Object} ev
*/
onIEMouse: function() {
if (event.button > 1) {
if(window.event.srcElement.id == RightClick.FlashObjectID && RightClick.Cache == RightClick.FlashObjectID) {
RightClick.call();
}
document.getElementById(RightClick.FlashContainerID).setCapture();
if(window.event.srcElement.id)
RightClick.Cache = window.event.srcElement.id;
}
},
/**
* Main call to Flash External Interface
*/
call: function() {
document.getElementById(this.FlashObjectID).rightClick();
}
}
[/javascript]

On the Flash side is as simple as this code (AS3):

[as]
package {

import flash.display.*;
import flash.external.ExternalInterface;

public class RightClick extends Sprite
{

public function RightClick()
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

var methodName:String = “rightClick”;
var method:Function = onRightClick;
ExternalInterface.addCallback(methodName, method);
}

private function onRightClick():void {

var mx:int = stage.mouseX;
var my:int = stage.mouseY;

if(my > 0 && my < stage.stageHeight && mx > 0 && mx < stage.stageWidth) {
// YOUR CODE HERE
}
}
}
}
[/as]

This demo has been tested and confirmed working on:

WINDOWS VISTA

  • Internet Explorer 7.0.6001 (16549)
  • Firefox 2.0.0.6 (with mouse gestures disabled)
  • Maxthon 2 (with mouse gestures disabled)
  • Safari 3.0.3 (522.15.5)

Windows XP SP2

  • Internet Explorer 6
  • Internet Explorer 7
  • Maxthon 2 (with mouse gestures disabled)
  • FireFox 2 (with mouse gestures disabled)
  • Safari 3
  • Netscape 8

Mac OSX 10.4.10 (Intel)

  • Firefox 2
  • Safari 3.0.3

Thank you all for testing!

Opera will not work, the browser forces the context menu to appear and blocks mouse events by default.

If you manage to get the demo working, please post the OS and Browser build number in the comments. Please also leave a comment if you experience any problems with the demo.

Google Code Project

DEMO

DIGG THIS

.

Mediatemple.net DV4.0 Server

134 Responses to “SOLVED: Right Click in AS3”

  1. George Says:

    Not work for Linux?

  2. alex Says:

    Mac 10.4.10 (Intel) + FF 2.0 = true
    Mac 10.4.10 (Intel) + Safari 2.0 = false

  3. Marteinn Says:

    No love from Safari (Version 2.0.4 (419.3)) under Mac 10.4.10 under PPC either.

  4. Mirko Says:

    Finally a working solution :)

    Vista + Firefox 2.0.0.6 = true

  5. Tek Says:

    The problem with this solution is that you use wmode=”opaque” or wmode=transparent” to let the browser use its own windowing mode on the animation. There is bugs with Firefox on international keyboards when typing special symbols, @ sign and some other keys in input fields when wmode is set other than windowless. On French keyboard when you type @sign you will have the letter “à” in the input field.

    Setting wmode to opaque is also know to slightly reduce framerate on animations that use a lot of graphical rendering (wmode transparent reduce it noticeably).

  6. Benny Says:

    My list as tested on WinXP SP2:

    Internet Explorer 6: works
    Internet Explorer 7: works
    FireFox 2: works
    Opera 9 : doesn’t work
    Safari 3: works
    Netscape 8: works

  7. Rechtsklick in AS3 at flash und so… Says:

    [...] immer das Context-Menü des FlashPlayers, welches man auch selbst noch erweitern kann. Aber gibt es hier eine Lösung um die Rechts-Klick -Funktionalität selbst zu bestimmen. Die Lösung ist eine Kombination aus [...]

  8. Ahmet Says:

    Nice idea, but it works on all the page and not only over the Flash, a bad usability idea…

  9. Matthias Says:

    Not working on Linux (xubuntu) with either Firefox or Opera.

  10. Matthias Says:

    P.S.: Both browser are the latest stable versions.

  11. Are you still jumping out of windows in expensive clothes? » Blog Archive » Semesterlänkar Says:

    [...] Right Click In Flash http://polygeek.com/377_adobeflash/actionscript_custom-right-click-in-flash http://www.uza.lt/blog/2007/08/solved-right-click-in-as3/ Många har gett sig på högermenyn i flash, detta är ett av få exempel där menyn inte bara tas [...]

  12. Paulius Uza Says:

    Thanks to everyone for your comments!

    Ahmet: I have disabled the all-page effect by removing “oncontextmenu” events, thanks for pointing this out

    Matthias: I will try to get a linux box to test this out, thanks. Opera will not work, the browser forces the context menu to appear and blocks mouse events by default.

    Tek: I haven’t thought about this, I will take a look, thanks.

  13. polyGeek Says:

    Thanks for picking up the torch on this Paulius. I’ve added you as an owner on the Google Code project that I started. I’m sure that a reliable solution will be found and the Flash community will be able to take over the Flash context-menu!

  14. Simon Says:

    Doesn’t work in Mac OS X Safari or FF (EDIT BY UZA: Actually it works on the latest FF 2.0.0.6 on Mac OS X 10.4 Intel). Looks like Paulius is feeling the same pain as polyGeek – it also highlights exactly why Flash/Flex AS,2,3 are so superior to other scripting languages. At least in Flash you KNOW your stuff works in all browsers on 3 platforms. I have no idea how Google does it, they must have a kick-ass QA dept.

    This will rock if it ever works.

  15. MG Says:

    Context menu still appears in FF 2.0.0.6. Could be a mouse gestures issue?

  16. Paulius Uza Says:

    MG: Yes, this IS a Mouse Gesture issue. I can confirm that this solution does not work on browsers that have Mouse Gestures enabled.

    Such browsers are Opera, Mozilla Firefox (with plugin) and Maxthon (with plugin).

  17. Pingu Says:

    Firefox 2.0.0.6 on MacOS X 10.4.8 — work.
    Safari 2 on MacOS X 10.4.8 — not work

  18. wjn » No Right-click menu in flash: is it real? Says:

    [...] На блоге uza – интересная попытка совсем убрать стандар… [...]

  19. Uza’s Blog & More » Blog Archive » $.console - Flash Debugging Console Says:

    [...] last couple of days have been pretty busy for me trying to make some progress with the Right-Click functionality in Flash 9, it is coming together pretty good and I hope to have a working Linux version very [...]

  20. g_w_master Says:

    Windows XP SP2 + IE 6.0.2900.2180 No
    Windows XP SP2 + Firefox 2.0.0.6 Yes Yes Yes !!!!!!!! :)

  21. redrum Says:

    It’s not working for me on vista and firefox 2.0.0.6. If you rightclick in the gray area it shows the traditional context menu. If you click left on the flash area first, and then click right you get the same context menu like when you make a selection.

  22. Mike Owens Says:

    As someone who’s dealt with how browser plugins are implemented on X11 (Linux/Unix), I’d be surprised if this ever works there any time soon. Not your fault, though.

    It’s a major hack just to get page content to even overlap Flash on X11 using the normal Netscape plugin architecture. Basically, the plugin is going to sit on top of your page, catching events regardless of its z-index or what you’re trying to hook. You can think of it as like trying to capture events on a page while your email client is in front of the browser.

    It’d take something like the redirected drawing stuff Zack Rusin is working on to make this nicer. He’s talking in terms of Qt/KDE/WebKit, but the same idea would apply to Firefox/X11: http://zrusin.blogspot.com/2007/06/mirroring-widgets.html

  23. undolog » Blog Archive » Right Click in AS3: menu contestuali personalizzati Says:

    [...] caratteristica sarebbe interessante sia per i giochi che per le Applicazioni RIA. Paulius Uza ha proposto una soluzione per ActionScript 3 (AS3) che lavora in accoppiata con Javascript. Questa “patch” è ancora in fase di [...]

  24. Uza’s Blog & More » Blog Archive » Results: Right Click Says:

    [...] of all I would like to thank everyone for their great feedback regarding the Right-Click project. I have received thousands (!!!) of feedback emails with your browser data which helped me to [...]

  25. links for 2007-08-27 « napyfab:blog Says:

    [...] Uza’s Blog & More » Blog Archive » SOLVED: Right Click in AS3 (tags: actionscript flash as3 click flex right web development webdesign) [...]

  26. g_w_master Says:

    Windows XP SP2 + IE 6.0.2900.2180 Yes Yes Yes
    i has flash player problem

  27. Chuyue Says:

    It works well on IE6 and firefox2.
    I look forward to complete rightmouse event,like RIGHT_MOUSE_DOWN,RIGHT_DOUBLE_CLICK.
    Thank you for this!

  28. avery Says:

    http://johnjddeservio.com/forum/viewtopic.php?p=7315

  29. collette Says:

    http://www.thepeppermint.com/phpBB2/viewtopic.php?p=54030

  30. chu Says:

    http://wirelessfm.org/cirg/viewtopic.php?p=35524&sid=6753dbea77be755a60a33e3105d9da58

  31. debbi Says:

    http://omcity.free.fr/forum/viewtopic.php?p=4604

  32. Scott Says:

    Does not work on Firefox 2.0.0.8 on Windows XP SP2. Draws circle but context menu comes up when right-clicking on flash box. I do not use gesture plugins, but a few plugins I use do add options to the context menu, and I wonder if this is an issue since others have said Firefox 2.0.0.6 works…

  33. Adrian Says:

    Works for me.. (XP Firefox 2 flash 09.r60 )

    What’s Adobe position about this ?
    Is it..ya know…legal ?

  34. Paulius Uza Says:

    @Adrian:

    Adobe has expressed some interest into evolving right-click functionality in the future versions of Flash Player through unofficial channels, but no official statement has been made.

    From the legal side – this “hack” uses 100% standards compliant JavaScript and communicates with Flash Player through a bridge provided by Adobe – so yes, it is legal.

  35. booleanbetrayal» Blog Archive » delinquency and externalinterfaces Says:

    [...] way of dealing with the lack of full support for “right click” events in Flash. Check out this blog posting for more info. Another good use of ExternalInterface [...]

  36. AS3.0 中的 Flash右键触发与屏蔽 : FRONT-END STUDIO Says:

    [...] 可以看看介绍:http://www.uza.lt/blog/2007/08/solved-right-click-in-as3/,效果这里可以看到:http://www.uza.lt/rightclick/,代码这里可以下载到:http://code.google.com/p/custom-context-menu/。 PLAIN TEXT HTML: [...]

  37. oops Says:

    Hi Guys,
    it does not work in Safari 3.0.4.

    Can you look at it please? :)

    Thanks

    Tom

  38. Ben Says:

    Hey!

    I’ve just an hour ago got in from work, where today I had written a “right clicker” for AS3, and would you believe it – I scan a little on Google and I find this!

    A couple of notes!

    1] Opera: Press Ctrl+F12, or click to the preferences… choose “Content” and find the “JavaScript options…” button, can you believe it? Why on earth did they do that?

    2] With that disabled you have a new problem, just disable the darn flash context menu the usual way… (in script/on publish)

    There you have it, the definitive right click solution!

    PS: Put the JS in a and then use ExternalInterface.call(“eval”, …) to inject it into the page, now you have a single solution! Another idea would be to dispatchEvent(MouseEvent.RIGHTCLICK…); – the right click event is there for Air applications, so now you have unified your in-browser/desktop code without compromising functionality.

    Oh and Happy New Year! :o)

  39. Ben Says:

    note: where it says “PS: Put the JS in a and…”

    It should say CDATA…

  40. Ben Says:

    PPS: *rollseyes*

    RE (anyone with a browser it won’t work in):

    Another way to have right click is to create a ‘div’ and ‘spacer.gif’ to sit above the flash ‘div’…

    Handling ordinary flash mouse events is a bit of a longhaul JS-AS hack but it works, you can use a cheap dispatchEvent or better still swap the z-index/show-hide the div… its a pain to implement but onces its wired up its good to go.

  41. T.Girish Kumar Says:

    These Script working in only Cs3 or Flash 8 and mx Proffessional also Pls Confirm.There is no working in Flash 8.I am Checked.Pls Clarify in any clarifications and modify in that code working to flash 8.because my project is already working in flash 8 and mx proffessional.I am waiting for ur reply.
    Thank u

  42. Michael Fox Says:

    Cool good work. Just interested if there is a solution for Flash8

  43. vishal Says:

    great work by you… thanks a lot..
    the code what u gave for the external interface calls error in flash can u explain how to apply this code of action script to call the external interface?

  44. elevent Says:

    FullScreen can not?

  45. adrian Says:

    you must be talking about the dreaded wmode bug in firefox.
    http://www.5etdemi.com/blog/archives/2005/06/firefox-wmodetransparent-is-completely-screwy-and-breaks-textfields/
    also look at the 5th response to this blog

  46. Obeliks Says:

    Hello,

    Is there a possibility to tell a flash- and javanoob like me, how to implement this?
    I have an index.htm and a …swf.
    Should I paste the script in the index.htm or call a script in the index?
    I hope someone will help me…

  47. quick cash advance advance cash now quick Says:

    gioca a poker on line…

    As a summary of telecharger jeu de poker gratuites payday loan cash advance loan…

  48. card casino free game online online casino game play casino game online Says:

    kostenlose online spiele casino 14 casino spiele online spielen…

    At the beggining card casino free game online payday cash loan…

  49. le casino gratuites sans dépot Says:

    jeux gratuits du casino jeux gratuits casino telecharger jeux casino gratuits…

    There casino en francais casino et bonus…

  50. poker texas hold spielen Says:

    le casino gratuites sans dépot…

    You jeu poker texas holdem gratuites poker pc spiel download…

  51. canadian payday loan Says:

    bonus dei casino…

    There poker de ases fast cash payday loan…

  52. advance advance america cash advance america cash advance advance advance america cash center inc Says:

    poker en linea…

    Consider advance cash loan loan payday table de poker en ligne…

  53. poker texana on line Says:

    poker in tour…

    Preview jouer poker sur internet jeu slots en ligne…

  54. faxless hour loan one payday hour in loan one payday hour loan one payday Says:

    jugar slots en linea…

    No cash advance payday loan instant loan online payday…

  55. Jelger Says:

    rightClick outside the flash,
    html menu appears,
    click anywhere outside the htmlMenu to remove the htmlMenu,
    now rightClick on the Flash,
    first rightclick will not be activated.

    anyway, thx a Million, very coOol;

  56. gotjosh Says:

    @Ben

    that eval trick === _#$c%in’_ hot.

    many thanks to uza and the rest of the testers and contributers!

    Adobe’s conservative stance is somehow understandable… but i totally agree that we are entering an age of multitouch displays… and flash player embedded in a browser is _ONLY_ giving us one button??? lame.

    but with an adaptation of this solution, together with swfMacMouseWheel… we can have cross platform, 3 button mouse with scroll wheel action!

    this rocks!

    ~gotjosh

    ps (i hope i can convince my boss that we ought to release our solution to y’all)

  57. apprendre le poker gratuites Says:

    world champion poker…

    Verdad play seven card stud poker sign up bonus juegos azar portales internet top poker promociones jouer video poker…

  58. Quarua Says:

    I posted a topic about right click on the Adobe forum here: http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=72&catid=675&threadid=1372314&enterthread=y

    Perhaps you’d like to offer suggestions or voice your opinion over there as well.

  59. Chan Says:

    Vista Ultimate 64bit + Firefox 3 + Flash 9 == true

  60. bigfoot Says:

    Not work for Solaris 10…..
    Mozilla & FireFox, all failed.

  61. Maeiky Says:

    I found a way to remove it and that’s work on all browser but we need to hack a file. If somebody has more skill to make a plugin with this, would be really nice. Take care because this will remove the right click on all flash movie on Web. For a local game this is perfect.

    http://membres.lycos.fr/micban/

  62. JaMaL Says:

    WOW!!! greatss ITS WORKINGGG..

  63. Sitthykun Says:

    Great,

  64. Rodrigo Gomez-Tagle Says:

    I have tried using this with swfObject 2.0 and it worked fine in.
    Mac FF 3.06
    but it didn’t in
    PC IE 6

    downgrading to swfObject 1.5 made it work across the board.

    Any plans of making it work with swfObject 2.0 ?

    good work, thanks.

  65. SubratKumar.com » Blog Archive » Right Click in AS3 Says:

    [...] You can download the file : RightClick_0[1].6.2.zip Nice to Visit : http://www.uza.lt/blog/2007/08/solved-right-click-in-as3. [...]

  66. Nielsio Says:

    Thanks, this works fantastic!!
    The only problem is on the Mac with a single button mouse.
    Due to pressing the Ctrl key the mouse event can’t be triggert. (Safari 3, Mac OS X)

    Does anyone knows a solution for this?

  67. Alex Says:

    In my Opera it does work but the context menu appears anyway. Any ideas to fix that?

  68. Malkomalko Says:

    I echo Nielsio’s response. I’m really looking for a way to disable the right click menu in safari based browsers (webkit) with the control click. Please let me know if anybody has any ideas.

  69. BoлкBepнyлcя Says:

    Текст лично мне ничего особенного не дал. Но вот для многих он может оказаться полезным… :)

  70. Hiraash Says:

    Hey this is great stuff. but right now im suffering with the same problem as Tek. the wmode issue. cant use anything other than wmode=”window”, it messes the keyboard input on firefox/chrome. Any help on this will be greatly appreciated.

  71. гoлЬeтти Says:

    Нерациональное употребление материальных благ зачастую является вернейшим путем к величайшим невзгодам.

  72. Marc Says:

    Doesn’t work with Safari 4 (final) under OS X 10.5.7 =/

  73. NewDanger Says:

    How can i get this for a Full Screen project?

  74. tat Says:

    hey i really need to have a copy of ur sample code which includes the drawing of dark circles, i have some problem in making it work

  75. Disable right click menu in Flash (swf files) « eInternals Says:

    [...] a method to completely disable the flash right menu. Check the article link at his website http://www.uza.lt/blog/2007/08/solved-right-click-in-as3 and the Demo here [...]

  76. Luis Says:

    MAC OS 10.5.7

    Firefox & SWFObject v1.5 = true;
    Safari & SWFObject v1.5 = false;

    Firefox & SWFObject v2 = false;
    Safari & SWFObject v2 = false;

  77. Luis Says:

    Safari 4 & firefox 3.5

  78. aki Says:

    how to use both code?

  79. Daniel Says:

    I can confirm that google chrome works as well. great job.

  80. Dominik Says:

    Is there really no chance to prevent right clicks for other wmode? We have to use FP10 “direct mode” to reach an acceptable frame rate in our game.

    Unfortunately, opening the standard FP menu with a right click, will occasionally freeze the whole browser (FF/IE) until you change to another application and then reactivate the browser window again.

  81. Arif Ali Saiyed Says:

    Hey it’s not working on Safari (Mac)

    http://code.google.com/p/custom-context-menu/issues/detail?id=10

  82. AS3 Right-click functionality | lordofduct.blog.get Says:

    [...] an article to this guy Uza’s blog who had a JScript for getting the functionality in AS3. The article found here caught my interest for some reason that I can’t explain. It probably had to do with the game [...]

  83. Zoulz Says:

    This works on Google Chrome too. Excellent! :)

  84. jagged software Says:

    Awesome, works in Chrome, Firefox and IE 6.0.2900.5512.xpsp_sp3_gdr

  85. J Says:

    Got it working with wmode=”opaque” but I want to use wmode=”direct”… any solution for that?

  86. Chris MacLeod Says:

    Working on XP SP2 with Google Chrome (1.0.154.48)

  87. OTLABS BLOG » Blog Archive » Full AS3 right click Says:

    [...] a bit of JS. Really useful in game development, as add a new key to the mouse. Here the link with a quick tutorial « pixel bender – setup :: | [...]

  88. Par Says:

    worked!!
    XP + Safari 4.0.3

    “Thanks for your source code”

  89. Gin rummy Says:

    It is possible to focus on the idea of your game rather than on how to improve the laggy experience. Its very true totally agreed with this.

  90. cfyong2020 Says:

    how about in action script 2.0??

  91. wee Says:

    This is so hackish ;). Good job.

  92. Filipe Says:

    Excellent Work!
    Would never have thought of it.

  93. Pang Pang Says:

    Can eliminate all right click menu in flash.
    Great job.
    Thank you very much. :)

  94. Vivian A. Carey Says:

    For some reason my browser doesn’t display this page correctly…Anyway,

  95. Teresa Says:

    It works in IE8 but throws an error. The error is meaningless but based on my debug seems to actually have something to do with this function. Already checked my AS3 code is correct. And it works except for the unspecified error.

    call: function() {
    document.getElementById(this.FlashObjectID).rightClick();
    }

    I am not a js expert so I could really use some assistance here. Even a good debug tool for IE. Any suggestions?

  96. luqin Says:

    看不懂

  97. Mark Radocy Says:

    This is all really neat, but it doesn’t work on all browsers. I guess that’s unavoidable.

    But is there a way for the code to detect if it doesn’t work? That would make it easier for game devs

  98. andy93 Says:

    Eureka,Why would anyone want to do this? Well, there are several very important reasons: 1) Games

  99. mike Says:

    谢谢

  100. Jacob Says:

    Works fine on Windows XP Pro with Google Chrome

  101. Иришка Says:

    Однако, автор кошерно опубликовал.

  102. world cup 2010 betting tips Says:

    Just want to say what a fantastic blog you got here! I’ve been around for quite plenty of time, but now decided to show my appreciation of your work! Well done, and all the best!

  103. steve Says:

    This is great… but does not work with Titanium unfortunately.

  104. Paul Says:

    Works great on Mac OSX 10.6.2 using Chrome and FF without any problemas at all.

    Thx man.

  105. Paul Says:

    Works normally with Windows 7 (professional) and Google Chrome (not sure what version).

  106. Paul Says:

    By the way I’m not sure what version this copy of Windows 7 is..

  107. Paul Says:

    And by the way, I’m the above 2 Pauls, the one above that is a different Paul.

  108. Paul Says:

    I cant make it works with my project… I mean, Im using Flash Builder (Flex 4) and I have the latest version of SWFObject, and a completly different HTML tamplate.. so, cant find a way to merge this two stuffs :P

  109. 利用AS3.0和javascript屏蔽网页中的Flash右键菜单 | Riaelite's Blog Says:

    [...] 原地址:http://www.uza.lt/blog/2007/08/solved-right-click-in-as3/ 效    果:http://www.uza.lt/rightclick/ 下    载:http://code.google.com/p/custom-context-menu/。 [...]

  110. Kaustav Majumder Says:

    Hey can u get this thing to work on Standalonew Shockwave files?

  111. poker Says:

    This is all really neat, but it doesn’t work on all browsers. I guess that’s unavoidable.

    But is there a way for the code to detect if it doesn’t work? That would make it easier for game devs

  112. : Niews ArkLab » Blog Archive » -滑鼠右鍵對遊戲的重要性- Says:

    [...] 這是Uza,s Blog中提出的一個解決方案,首先,我們要在ActionScript註冊一個callback,方便JavaScript通知ActionScript,當使用者按下右鍵時,JavaScript要執行最重要的兩件事,禁用滑鼠右鍵,同時發訊息給ActionScript,然後ActionScript接收到訊息之後,再執行該做的事情,事實上,這個流程意謂著一件事情,就是按右鍵這個動作在JavaScript處理程序時就被擋下來了,ActionScript做的事情就只是等待JavaScript給一個通知,然後做該做的事情,完全跟右鍵無關。 [...]

  113. Craig Says:

    Works for:
    Windows 7 Ultimate – Google Chrome 6.0.472.55

  114. daniel.seldacek Says:

    Just a note: be careful with opaque or transparent wmode, see what Tinic Uro says:
    old one (but still true for backward compatibility):
    http://www.kaourantin.net/2005/01/wmode-and-flash-video.html
    new one:
    http://www.kaourantin.net/2010/02/core-animation.html

  115. Vladik Says:

    Works for:
    Windows 7 – Home edition – Google Chrome 8.0.522

  116. ZREN Says:

    Thanks, it’s very helpful for me.
    http://www.as3tutorial.com is very helpful for beginners.

  117. james Says:

    how do i implement the as3 package into my .fla project?

  118. Alongkorn Says:

    Internet Explorer 9: doesn’t work
    nternet Explorer 8: doesn’t work
    FireFox 5: works

  119. iwonk Says:

    Please help me.
    How to use it AS2?

  120. moon Says:

    Can’t it realize without using “wmode”?

  121. Dear /expletive/ Adobe « Indigo Static Says:

    [...] for other things than displaying a f*cking context menu. We’ve even gone to the extremes of hacking around your applet, even if said hacks are never compatible with every browser out there (I’m looking at you [...]

  122. Charly Says:

    This works perfectly on your web page.
    However, I was trying it in a personal environment for testing, just by copying the 4 files (HTML / both JS / SWF file) and no luck.
    Every time I open the page, I get one of the two results – The context menu will function, or no response from a right click.

    Any ideas on the cause?

  123. Wilson Silva Says:

    This issue is solved since Flash Player 11.2 when MouseEvent.RIGHT_CLICK event was added.

  124. Anton Says:

    It works when the link to the movie is like this
    movie.swf
    but not when it’s like this
    something.com/movie.swf

    What’s the problem? Thanks.

  125. Mi Apuesta Says:

    This is a great solution to the java issue, but it’s already solved by the player itself in the latest version. Anyway is great to think other ways.

  126. Deeanna Hinostroza Says:

    Hi there everybody, here every one is sharing such experience, so it’s fastidious to read this webpage, and I used to go to see this webpage all the time.

  127. joe Says:

    is there a way to detect when you release the right mouse button?

  128. alex Says:

    my mouse wheel does not get through, why is this?

    email me the answer discipol333 at yahoo.com

  129. Using Right Click in Captivate flash file Says:

    [...] [...]

  130. chao Says:

    This will not work in Stage3D programs while wmode=”direct”.
    Why?

  131. Getting rid of the Default Context Menu on Flash Apps « jd's transparency : software design & data visualization Says:

    [...] is not very legal but still simple to do, read this article: http://www.uza.lt/2007/08/19/solved-right-click-in-as3/ . You’re not only able to remove the context menu but also to specify your own custom one, [...]

  132. jd Says:

    Since the latest update in Chrome browser, you should use the code snapshot listed here:
    http://jds-transparency.com/2012/08/07/getting-rid-of-the-default-context-menu-on-flash-apps/

    Also, notice your mouse wheel won’t work until you fix this with the following code:

    // Detect all browsers except IE (In IE mouse wheel works fine without workarounds)
    if(!(document.attachEvent)) {
    var eventType = “mousewheel”;

    if (navigator.userAgent.indexOf(‘Firefox’) !=-1) {
    // For Firefox we must use DOMMouseScroll event
    var eventType = “DOMMouseScroll”;
    }

    window.addEventListener(eventType, mouseWheelHandler, false);
    }

    function mouseWheelHandler(event) {
    var app = document.getElementById(“SuiteApplication”);
    if (app) {
    var edelta = (navigator.userAgent.indexOf(‘Firefox’) !=-1) ? -event.detail : event.wheelDelta/40;

    var o = {
    delta: edelta,
    ctrlKey: event.ctrlKey,
    altKey: event.altKey,
    shiftKey: event.shiftKey
    }
    app.mouseWheelHandler(o);
    }
    }

  133. Paulius Uza Says:

    Thanks jd! version 0.7.0 is now on google code, with SWFObject 2.2 included by default.

  134. Matt Koss Says:

    Hello there, just trying the rightclick.js and after a lot of different tries, I just can’t get it to work.

    Always getting document.getElementByID is null …
    I am running on IE 8.
    It seems that when RightClick.init() function gets invoked, “flashcontent” is not present.
    Even when I move “script” section after the flashcontent div is defined, it makes no difference.
    I tried to bind RightClick.init() to both body.onLoad(), as well as a parameter to the swfobject.embedSWF() function, with the same results.

    Your demo actually works fine in my browser, but I noticed from “view source” that you are not using embedSWF function there, but calling “new SWFObject” directly.
    Can this be a culprit ?

    I am using the swfobject.js as published on the project’s website togther with rightClick.js, so hopefully there is no version issue here …