码迷,mamicode.com
首页 > 其他好文 > 详细

设置 menu 菜单 监听

时间:2015-06-11 09:22:07      阅读:134      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!