咖啡伴侶

          呆在上海
          posts - 163, comments - 156, trackbacks - 0, articles - 2
          實(shí)現(xiàn)第一步,屏蔽默認(rèn)菜單后:
          http://www.aygfsteel.com/oathleo/archive/2011/11/28/365009.html
          接下來(lái)就是實(shí)現(xiàn)自定義菜單了

          先看結(jié)果:


          就實(shí)現(xiàn)了兩層,沒有考慮多層菜單,菜單項(xiàng)用簡(jiǎn)單的button實(shí)現(xiàn),感覺還行

          主要的代碼如下:
                  private var titleWindow:Group;
                  
          private var pointNameGroupMenu:VGroup;
                  
          private var secondMenu:VGroup;
                  
                  
          public function hiddenPopupMenu():void{
                      
          if(titleWindow != null){
                          PopUpManager.removePopUp(titleWindow);
                          pointNameGroupMenu 
          = null;
                          secondMenu 
          = null;
                      }
                  }
                  
          private function showPopupMenu(allInterestPointNames:HashSet,physical_x:int,physical_y:int):void {
                       
          if(allInterestPointNames.size == 1){
                           titleWindow 
          = prepareDetailMenu(physical_x,physical_y);
                       }
          else{
                           titleWindow 
          = new Group();   
                           titleWindow.x 
          = physical_x;
                           titleWindow.y 
          = physical_y;
                           
                           pointNameGroupMenu 
          = new VGroup();   
                           pointNameGroupMenu.gap 
          = 0;
                           pointNameGroupMenu.horizontalAlign 
          = "contentJustify";
                           
                           titleWindow.addElement(pointNameGroupMenu);
                           allInterestPointNames.forEach(function(_node:String):
          void{
                               var _point_name:Button 
          = new Button();
                               _point_name.label 
          = _node;
                               pointNameGroupMenu.addElement(_point_name);
                               _point_name.addEventListener(MouseEvent.MOUSE_OVER,showSecondMenu);
                           });
                       }
                       PopUpManager.addPopUp(titleWindow, viewer, 
          false);   
                  }
                  
                  
          private function prepareDetailMenu(_x:int,_y:int):VGroup{
                      var detailGroup:VGroup 
          = new VGroup();   
                      detailGroup.gap 
          = 0;
                      detailGroup.horizontalAlign 
          = "contentJustify";
                      detailGroup.x 
          = _x;
                      detailGroup.y 
          = _y;
                      
                      var _button_point_info:Button 
          = new Button();
                      _button_point_info.label 
          = ResourceUtil.getString("gview_popup_pointinfo");
                      detailGroup.addElement(_button_point_info);
                      
                      var _button_point_trend:Button 
          = new Button();
                      _button_point_trend.label 
          = ResourceUtil.getString("gview_popup_trend");
                      detailGroup.addElement(_button_point_trend);
                      
                      
          return detailGroup;
                  }
                  
                  
          private function showSecondMenu(evt:MouseEvent):void {
                      var _evt_target:Button 
          = Button(evt.target);
                      var _index:
          int = pointNameGroupMenu.getChildIndex(_evt_target);
                      
          if(secondMenu == null){
                          secondMenu 
          = prepareDetailMenu(pointNameGroupMenu.measuredWidth,_evt_target.height * _index);
                          titleWindow.addElement(secondMenu);
                      }
          else{
                          secondMenu.y 
          = _evt_target.height * _index;
                      }
                  }

          主站蜘蛛池模板: 乐清市| 黄陵县| 三台县| 历史| 布拖县| 石门县| 体育| 临洮县| 措美县| 大城县| 栖霞市| 永福县| 日土县| 上思县| 东平县| 增城市| 福鼎市| 扬州市| 唐海县| 韶关市| 塔河县| 沙雅县| 来凤县| 房产| 涟源市| 西城区| 洛川县| 木兰县| 水城县| 荃湾区| 安宁市| 健康| 衡阳县| 噶尔县| 邢台市| 闻喜县| 龙井市| 莆田市| 南溪县| 江口县| 沅陵县|