• 给SP添加 自定义右键菜单比较符合


    package  {
    	
    	import flash.display.MovieClip;
    	import flash.events.MouseEvent;
    	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 MovieClip {
    		
          /*      
            *author : SinSoul     
            *blogs: http://www.cnblogs.com/sinsoul
              */
          
     
    		private var onMenu:ContextMenu;  
                    private var onBuiltMenu:ContextMenuBuiltInItems; 
    		private var contextItem:ContextMenuItem;
    		
    		public function Main() {
    			// constructor code
    			init();
    			removeDefaultItems(); 
    		}
    		private function init():void
    		{
    			removeDefaultItems();
    			mc.addEventListener(MouseEvent.MOUSE_MOVE, onmcMoveHandler);
    			mc1.addEventListener(MouseEvent.MOUSE_MOVE, onMc1MoveHandler);
    			mc2.addEventListener(MouseEvent.MOUSE_MOVE, onMc2MoveHander);
    		}
    		private function onmcMoveHandler(e:MouseEvent):void
    		{
    			
    			trace(1);
    			removeDefaultItems();
    			contextItem = new ContextMenuItem("sinsoul", true);  
    			 contextItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, openURL); 
                onjinruHandler();
    		}
    		private function onMc1MoveHandler(e:MouseEvent):void
    		{
    			removeDefaultItems();
    			//var contextItem:ContextMenuItem=new ContextMenuItem("孩子",true);  
    			contextItem = new ContextMenuItem("孩子", true);
                //onMenu.customItems.push(contextItem);  
                contextItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, openURL1); 
    			onjinruHandler();
    		}
    		private function onMc2MoveHander(e:MouseEvent):void
    		{
    			removeDefaultItems();
    			//var contextItem:ContextMenuItem=new ContextMenuItem("老子",true); 
    			contextItem = new ContextMenuItem("老子", true);
                //onMenu.customItems.push(contextItem);  
                contextItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, openURL2); 
    			onjinruHandler();
    		}
    		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 openURL(evt:ContextMenuEvent):void
    		{   
    			navigateToURL(new URLRequest("http://www.cnblogs.com/sinsoul"));  
            }
    		private function openURL1(evt:ContextMenuEvent):void
    		{   
    			navigateToURL(new URLRequest("http://www.baidu.com"));  
            }
    		private function openURL2(evt:ContextMenuEvent):void
    		{   
    			navigateToURL(new URLRequest("http://www.qq.com"));  
            }
    		private function onjinruHandler():void
    		{
    			onMenu.customItems.push(contextItem);  
                //contextItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, openURL);
    		}
    
    
    	}
    	
    }
    
  • 相关阅读:
    SQL条件的顺序对性能的影响
    在客户端通过外部表访问Trace文件的内容
    Vue 数据持久化
    .Net 垃圾回收机制原理(一)
    密码管理工具KeePass
    SQL Server附加数据库 5123
    网页编码就是那点事
    你真想到了50岁还靠编程来养家糊口吗?
    技术敏感度 — 基层技术管理者必备
    虚拟化、云计算
  • 原文地址:https://www.cnblogs.com/sinsoul/p/2026849.html
Copyright © 2020-2023  润新知