在Flash中管理鼠标右键

在Flash中管理鼠标右键

//最大限度的把鼠标的右键菜单去掉 :stage.showDefaultContextMenu = false;

package {

import flash.display.Sprite;

import flash.events.ContextMenuEvent;

import flash.net.URLRequest;

import flash.ui.ContextMenu;

import flash.ui.ContextMenuBuiltInItems;

import flash.ui.ContextMenuItem;

import flash.net.navigateToURL;


public class Main extends Sprite {

private var onMenu:ContextMenu;

private var onBuiltMenu:ContextMenuBuiltInItems;

public function Main() {

init();


}

private function init():void{


removeDefaultItems();

addCustomMenuItems();


}

private function removeDefaultItems() {

onMenu =  new ContextMenu();

this.contextMenu=onMenu;

onMenu.hideBuiltInItems();

onBuiltMenu=onMenu.builtInItems;

onBuiltMenu.print=true;//不需要时,可以把myBuiltMenu = myMenu.builtInItems;myBuiltMenu.print = true;注销掉

}

private function addCustomMenuItems() {

var contextItem:ContextMenuItem=new ContextMenuItem("sinsoul",true);

onMenu.customItems.push(contextItem);

contextItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, openURL);

}

private function openURL(evt:ContextMenuEvent):void {

navigateToURL(new URLRequest("http://www.cnblogs.com/sinsoul"));

}

}

}

posted on 2011-06-26 11:54  Morris  阅读(221)  评论(0编辑  收藏  举报

导航