flex tree加入右键菜单


<mx:cavas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%"  creationComplete="init();">
private var newBuildMenuItem: ContextMenuItem;

internal function init(): void{
				treeMenu();
			}

private function treeMenu(): void{
				createTreeMenuItem();
				tree.contextMenu = getTreeContxtMenu();
			}

public function createTreeMenuItem(): void{
				newBuildMenuItem = new ContextMenuItem("新建");
				newBuildMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, newBuildHandler);
			}
			
			private function getTreeContxtMenu(): ContextMenu{
				var contextMenu: ContextMenu = new ContextMenu();
				contextMenu.hideBuiltInItems();
				contextMenu.customItems.push(newBuildMenuItem);
				return contextMenu;
			}

你可能感兴趣的:(JavaScript,Flex)