我的漫漫程序之旅

          專注于JavaWeb開發
          隨筆 - 39, 文章 - 310, 評論 - 411, 引用 - 0

          導航

          <2009年2月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          1234567

          常用鏈接

          留言簿(39)

          隨筆檔案(43)

          文章分類(304)

          文章檔案(257)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          China flashMap 的實現(AS3)

          網上有些例子不是不完善就是pay money的.自已整蠱了個.



          部分代碼:

          /*------------------------------------------------*/
          stop();
          tipBord.visible
          =false;
          mapBord.addEventListener(MouseEvent.MOUSE_MOVE,mapMove);
          mapBord.map.addEventListener(MouseEvent.MOUSE_OVER,mapHit);
          mapBord.map.addEventListener(MouseEvent.MOUSE_OUT,mapOut);
          mapBord.textBord.addEventListener(MouseEvent.MOUSE_OVER,visibleTip);
          mapBord.map.addEventListener(MouseEvent.CLICK,openURL);
          tipBord.addEventListener(MouseEvent.MOUSE_OVER,visibleTip);
          //鼠標點擊事件
          function openURL(event:MouseEvent):void {
              
              var url:String 
          = returnURL(event.target.name);
              
          if(url.length > 4)
              
          {
                  navigateToURL(
          new URLRequest(returnURL(event.target.name)));
                  
               }

          }


          function returnURL(t:String):String 
          {
          return resetString(resultXML.area.(@id==t).@url);
          }



          appBg.appTitle.text
          =loaderInfo.parameters.t;
          function mapMove(event:MouseEvent):
          void {
                  
          //mapBord.x=32-(mouseX-stage.stageWidth/2)/12;
                  
          //mapBord.y=30-(mouseY-stage.stageHeight/2)/12;
          }

          //鼠標移動到某個省市上的事件 
          function mapHit(event:MouseEvent):void {
              
          //得到輸入的xml中的value值
              var s :String =  returnValue(event.target.name);
                  
          //鼠標放到具體省市上的相應圖變色
                  event.target.nextFrame();
                  
          //有值
                  if(s.length > 2)
                  
          {
                      
          //顯示
                      showTip(event.target.name);
                  }

                  
          else
                  
          {
                      
          //隱藏上次顯示的tip
                      tipBord.visible=false;
                  }

          }

          function mapOut(event:MouseEvent):
          void {
              event.target.prevFrame();
              
          //hideTip();
          }

          function showTip(t:String):
          void {
              tipBord.visible
          =true;
              tipBord.t.htmlText
          =returnValue(t);
              var tz:Object
          ={x:0,y:0};
              tz.x
          =mapBord.textBord.getChildByName(t).x;
              tz.y
          =mapBord.textBord.getChildByName(t).y;
              var p:Number
          =0;
              var l:Number
          =0;
              
          if(tz.x>stage.stageWidth/2{
                  p
          =-120;
              }
           else {
                  p
          =120;
              }

              
          if(tz.y>stage.stageHeight/2{
                  l
          =-120;
              }
           else {
                  l
          =120;
              }

              tipBord.x
          =tz.x+p;
              tipBord.y
          =tz.y+l;
              gs.graphics.clear();
              gs.graphics.lineStyle(
          10xFFFFFF,0.1);
              gs.graphics.moveTo(tz.x
          +12,tz.y+6);
              gs.graphics.beginFill(
          0x0077CC,0.2);
              gs.graphics.lineTo(tipBord.x
          -32,tipBord.y-30);
              gs.graphics.lineTo(tipBord.x
          -32+tipBord.width-8,tipBord.y-30);
              gs.graphics.lineTo(tz.x
          +12,tz.y+6);
              gs.graphics.endFill();
              gs.graphics.moveTo(tz.x
          +12,tz.y+6);
              gs.graphics.beginFill(
          0x0077CC,0.1);
              gs.graphics.lineTo(tipBord.x
          -32+tipBord.width-8,tipBord.y-30);
              gs.graphics.lineTo(tipBord.x
          -32+tipBord.width-8,tipBord.y-30+tipBord.height-8);
              gs.graphics.lineTo(tz.x
          +12,tz.y+6);
              gs.graphics.endFill();
              gs.graphics.moveTo(tz.x
          +12,tz.y+6);
              gs.graphics.beginFill(
          0x0077CC,0.2);
              gs.graphics.lineTo(tipBord.x
          -32+tipBord.width-8,tipBord.y-30+tipBord.height-8);
              gs.graphics.lineTo(tipBord.x
          -32,tipBord.y-30+tipBord.height-8);
              gs.graphics.lineTo(tz.x
          +12,tz.y+6);
              gs.graphics.endFill();
              gs.graphics.moveTo(tz.x
          +12,tz.y+6);
              gs.graphics.beginFill(
          0x0077CC,0.1);
              gs.graphics.lineTo(tipBord.x
          -32,tipBord.y-30+tipBord.height-8);
              gs.graphics.lineTo(tipBord.x
          -32,tipBord.y-30);
              gs.graphics.lineTo(tz.x
          +12,tz.y+6);
              gs.graphics.endFill();
          }

          function hideTip():
          void {
              tipBord.visible
          =false;
              tipBord.t.htmlText
          ="";
              gs.graphics.clear();
          }

          function visibleTip(event:MouseEvent):
          void {
              
              tipBord.visible
          =true;
          }

          function returnValue(t:String):String 
          {
              
          return resetString(resultXML.area.(@id==t).@value);
          }

          function resetString(s:String):String 
          {
              var a:Array
          =s.split(",");
              var t:String
          ="";
              
          for(var i:uint=0;i<a.length;i++{
                  t
          +=a[i]+"\n";
              }

              
          return t;
          }


          demo and source

          demo and source other address for download

          posted on 2009-02-12 17:29 々上善若水々 閱讀(2492) 評論(4)  編輯  收藏

          評論

          # re: China flashMap 的實現(AS3)  回復  更多評論   

          如果某個省市不需要顯示tip或url的時候用url="#" or value="#" 或干脆不寫這個屬性即可.
          2009-02-12 17:31 | 々上善若水々

          # re: China flashMap 的實現(AS3)  回復  更多評論   

          good
          2009-02-12 22:39 | first_learner

          # re: China flashMap 的實現(AS3)  回復  更多評論   

          靠,這也算?
          看看我的
          2009-02-12 23:44 | cnflex.org

          # re: China flashMap 的實現(AS3)  回復  更多評論   

          @cnflex.org
          側重點不同而已,別做了個Flex整站程序就在這裝.你牛B把源代碼來出來分享下,
          沒有分享精神,請Shut up your mouth.
          2009-02-13 08:58 | 々上善若水々

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 宜州市| 板桥市| 大厂| 平罗县| 怀安县| 库尔勒市| 阿尔山市| 甘德县| 上犹县| 阿瓦提县| 五河县| 乌苏市| 阿合奇县| 宁夏| 竹山县| 济南市| 株洲县| 沾化县| 突泉县| 石河子市| 天峻县| 阳山县| 灌南县| 元谋县| 塔河县| 蛟河市| 隆林| 仙游县| 饶阳县| 通许县| 板桥市| 大安市| 隆子县| 马公市| 义马市| 新津县| 个旧市| 宁南县| 旅游| 荃湾区| 松原市|