标签:
//设置 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"){ }*/ }
标签:
原文地址:http://www.cnblogs.com/regalys168/p/4568020.html