我的漫漫程序之旅

          專注于JavaWeb開發
          隨筆 - 39, 文章 - 310, 評論 - 411, 引用 - 0
          數據加載中……

          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 々上善若水々 閱讀(2489) 評論(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 | 々上善若水々

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


          網站導航:
           
          主站蜘蛛池模板: 咸丰县| 从化市| 宕昌县| 临邑县| 讷河市| 岚皋县| 新乐市| 马尔康县| 南昌市| 尉犁县| 清水河县| 桐柏县| 甘德县| 吉林市| 松原市| 抚远县| 平度市| 胶南市| 平江县| 鄄城县| 兴海县| 阿城市| 蓬安县| 新邵县| 香河县| 怀化市| 务川| 恩平市| 普洱| 苍南县| 白朗县| 余干县| 秦安县| 佳木斯市| 海口市| 连山| 海兴县| 永嘉县| 庐江县| 福建省| 平舆县|