Thursday, January 15, 2009

Protect Your Game From Right Clicks!!

Right click any flash file, a menu will show up with many items, in the middle you will find "Rewind" and "Forward", those two items allows the user to move from frame to frame in the flash file.







This will be a bug in the game or an easy cheat for players to jump from level to level if each level of the game has its own frame.

The solution is to disable right clicks, as in the example below:





The following code shows you how to do that:

__________________code start____________________

var menu:ContextMenu = new ContextMenu(); //Instance of ContextMenu menu.hideBuiltInItems(); //Hide the default items

var item1:ContextMenuItem = new ContextMenuItem("All rights reserved");//Creating an item

menu.customItems.push(item1);//Adding the item to the menu

this.contextMenu = menu;//Apply our menu plz!

__________________code end____________________

This code will remove the items from the menu and add an item that says "All rights reserved".

You may creat new items and push them to the menu.

Write this code in the first frame in your flash file to disable right clicks in all frames.

Download the source file

Enjoy !


No comments:

Post a Comment