The right click menu in flash has some nice options on it, however it also allows for easy cheating in many types of games. By disabling the right click menu you can stop that cheating, and ensure your flash game is played the way it was meant to be. In this tutorial, I’ll be teaching you the actionscript 2 you need to disable the right click menu. With this code you will be able to get rid of the cheating options in flash’s right click menu, and even add a link back to your site.

First, I’ll explain why you should get rid of those extra features in flash’s right click menu. Options such as forward and back will allow players to skip around the frames in your game. It’s easy to see how this could become a problem in games with multiple levels or rooms to unlock, where all the levels are on separate frames. Players could just move from frame to frame by using the right click menu, instead of taking the time to play your game as they should.

Now that you know why you should get rid of the right click menu, it’s time to learn how to do it. Here’s the actionscript 2 code:

var rightClick:ContextMenu = new ContextMenu();//create a new right click menu called rightClick
rightClick.hideBuiltInItems();//hide the built in options of the right click menu
_root.menu = rightClick;//make the neccesary changes to the right click menu

That’s nice if you just want to stop cheaters, but suppose you want to add a link to your site in the right click menu. Here’s what your new code would look like:

function mySiteLink () {//add a new function called mySiteLink
getURL("http://freelanceflashgames.com/news/", "_blank");//create a new window and go to FreelanceFlashGames.com/News/
}//end function
 
var rightClick:ContextMenu = new ContextMenu();//create a new right click menu called rightClick
rightClick.hideBuiltInItems();//hide the built in options of the right click menu
_root.menu = rightClick;//make the neccesary changes to the right click menu
 
var mySiteLink:ContextMenuItem = new ContextMenuItem("FreelanceFlashGames", mySiteLink);//create a custom right click tab that goes to your site when clicked.
rightClick.customItems.push(mySiteLink);//put the custom right click tab into the right click menu

Now you can stop those cheaters and even put in a link back to your site, all from the right click menu.

Related posts:

  1. Tutorial to Stop Cheaters in a Maze Game using AS2
  2. How to Disable Tab Button Cheating using AS2
  3. Code Bits: Timeline