首页 > 其他 > 详细

设置 menu 菜单 监听

时间:2015-06-11 09:19:15      阅读:263      评论:0      收藏:0      [点我收藏+]
        //设置 menu菜单监听			
		public  function addMenuListener(selectedBtn:String):void{
			
			for(var i:int = 1;i< 5;i++){				
				if( this.menu["menuBtn"+i] !=  null){									 
				   this.menu["menuBtn"+i].buttonMode = true;														
				   this.menu["menuBtn"+i].mouseChildren = false;														
				   this.menu["menuBtn"+i].mouseEnabled = true;														
				   this.menu["menuBtn"+i].gotoAndStop(1);																       
				   this.menu["menuBtn"+i].addEventListener(MouseEvent.CLICK, onMenuBtnClick);				
				   this.menu["menuBtn"+i].addEventListener(MouseEvent.ROLL_OVER, onMenuBtnMouseOver);				
				   this.menu["menuBtn"+i].addEventListener(MouseEvent.ROLL_OUT, onMenuBtnMouseOut);								   				   
				}else{
					trace("没有找到这个元件!");
				}
			}							
			//选中状态				   
			this.menu[selectedBtn].removeEventListener(MouseEvent.CLICK, onMenuBtnClick);				
			this.menu[selectedBtn].removeEventListener(MouseEvent.ROLL_OVER, onMenuBtnMouseOver);				
			this.menu[selectedBtn].removeEventListener(MouseEvent.ROLL_OUT, onMenuBtnMouseOut);												   
			this.menu[selectedBtn].gotoAndStop(10);																				
			
		}		
		//提示按钮  移动上去  显示提示框 
		private function onMenuBtnMouseOver(event:MouseEvent):void {										
			event.currentTarget.gotoAndPlay(2);															
		}
		//提示按钮  移动上去  显示提示框 
		private function onMenuBtnMouseOut(event:MouseEvent):void {					
			event.currentTarget.gotoAndStop(1);												
		}		
		//提示按钮点击之后  弹出panel
		private function onMenuBtnClick(event:MouseEvent):void {           
			//获取 btn的编号   尾号作为图片arr的序列
		  	//var btnNum:int = event.currentTarget.name.charAt(3);								
			trace("点击的是:"+event.currentTarget.name);			
			
			addMenuListener(event.currentTarget.name);		
			
			
			/*if(event.currentTarget.name == "menuBtn1"){
				
				
			}*/
			
		}

  

设置 menu 菜单 监听

原文:http://www.cnblogs.com/regalys168/p/4568020.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!