Archive
July, 2009
Browsing all articles from July, 2009
2

The right click menu is actually called the context menu. I did not know that. I had to go through several forums and blogs on the net before stumbling upon this piece of information.

Usually one does not need to bother about this menu. But if you are working on a game, you might want to disable this menu. Because the ‘play’ option in the context menu gives your user the ability to play the movie when you would rather have it to stopped. I leave it up to your imagination figuring out how one can cheat or mess things up from here.

To disable the context menu, put this line of code on the first frame, or in any other frame from where you want the context menu to be disabled.

stage.showMenu =  false ;

This will not actually disable the context menu, but hide most parts of it.

Disabling the context menu would help those would be cheaters from cheating their way through your game. But that’s not all we can do with this menu. We can also add some customized menu options as well. To do so, one has to follow these simple steps.

  • Make a new context menu
  • Create customized menu item
  • Attach event listener with the custom menu item
  • Insert the custom item into the new menu
  • Set the new menu as the current context menu

For example, in our games we usually put a customized menu item linking back to our homepage. To do this, we use the following piece of code.

function initMenu() {
	var m:String='© muktosoft';

	var cm:ContextMenu=new ContextMenu();
	var item:ContextMenuItem=new ContextMenuItem(m);

	item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,gotoMukto_);
	cm.hideBuiltInItems();
	cm.customItems.push(item);
	this.contextMenu = cm ;

}

function gotoMukto_(evt:ContextMenuEvent):void {
	navigateToURL(new URLRequest("http://www.muktosoft.com"), "_blank");
}
1

Stroke hinting

Anyone who have tried making rectangles with rounded corner must have noticed how odd those corners look as they tend to get pixelated and stick out from the body of the rectangle. See the image bellow if you still don’t get what I mean. Notice how odd those pixalted corners look. The same thing can happen with a curved line as well.

stroke_hinting_pixelated

This is due to the anti-aliasing performed on the curved lines by flash. This looks worst when the rounded part is small. The problem is still present when the curved part is large, but it becomes less noticeable. Anti-aliasing is generally a very helpful feature. This case is one of the rare exceptions when anti-aliasing is better not performed.

To let flash know that you don’t want anti-aliasing to be performed on your curved lines, you have to enable stroke hinting. When stroke hinting is used, flash colors the whole pixels only during rendering. Skips the fractional pixels. Thus anti-aliasing is avoided. See result after enabling stroke-hinting in the image bellow.

stroke_hinting_hinted