So you want to stop cheaters in your maze game? Maze games are a fun and simple way to start learning how to program flash. They’re pretty easy to make, and don’t require too much coding knowledge. Add the right features and art, and you might have a great game on your hand. But what happens when you realize that players are cheating to get by your perfectly designed mazes? That’s what I’ll be teaching you in this tutorial; how to stop those cheaters by adding a bit of Actionscript 2 code into your game.

The method I’ll be teaching you will detect when the player brings up the right click menu. Once the right click menu is brought up, the player will be taken to a cheating screen. I’ll leave what’s on the cheating screen up to you, just make sure you name the frame cheatFrame.

Here’s the AS2 code you’ll need:

var myMenu:ContextMenu = new ContextMenu();//create a new context menu called myMenu
function rightClick() {//create a new function called right click
gotoAndStop('cheatFrame');//when the right click button is pressed, go to the cheatFrame
myMenu.onSelect = rightClick;//when the right click menu is brought up, execute the rightClick function = myMenu;//make the neccesary changes to go to the cheating frame

This code will detect when a player hits the rght click button. When it is hit, the player will be taken to the cheat frame. Pretty easy to implement. If you do decide to use this method, take notice that it will work on all frames. So any frame that the player decided to right click on will take him to the cheating frame.

Related posts:

  1. How to Disable the Right Click Menu in Flash
  2. Code Bits: Timeline
  3. Custom Mouse Cursor Tutorial in Flash Actionscript 2