关闭

flex4 制作可拖动工具条

400人阅读 评论(0) 收藏 举报
分类:

   [Bindable]
   [Embed("Images/放大.png")]
   private var zoomin:Class;
   [Bindable]
   [Embed("/Images/缩小.png")]
   private var zoomout:Class;
   [Bindable]
   [Embed("/Images/平移.png")]
   private var pan:Class;
   [Bindable]
   [Embed("/Images/full1.png")]
   private var fullmap:Class;
   //工具条
   private function tbb_changeHandler(event:MouseEvent):void
   {
        switch (event.target.id)
        {
             case "fd":
             {
                 navTool.activate(NavigationTool.ZOOM_IN);
                 break;
             }
             case "sx":
            {
                 navTool.activate(NavigationTool.ZOOM_OUT);
                 break;
            }
            case "py":
            {
                 navTool.activate(NavigationTool.PAN);
                 break;
            }
            case "qt":
            {
                 this.map.zoomToInitialExtent();
                 break;
            }
            case "querry":
            {
                 this.queryfeture();
                 break;
            }
            case "print":
            {
                  this.printJpg();
                  break;
            }
            default:
            {
                 navTool.deactivate();
                 break;
            }
       }
   }
   //全屏  
   public function fullScreen():void{
    this.stage.displayState = (this.stage.displayState ==  
     StageDisplayState.NORMAL?StageDisplayState.FULL_SCREEN:StageDisplayState.NORMAL);  
    if(this.stage.displayState==StageDisplayState.FULL_SCREEN){  
     this.fullscreenbtn.label="返回";  
    }else{  
     this.fullscreenbtn.label="全屏";  
     
   }
   //查询
   private function queryfeture():void
   {
   }
  //打印某个控件当前内容以map为例
   private function printJpg():void//截单个UI
   {
    var bd : BitmapData = new BitmapData( UIComponent( map ) .width, UIComponent( map ) .height );
    var m : Matrix = new Matrix();
       bd.draw( UIComponent( map ) , m );
     var jpgp:PNGEncoder=new PNGEncoder();//PNGEncoder
     var ba2:ByteArray = jpgp.encode(bd);
     var file:FileReference=new FileReference();
     file.save(ba2,"未命名"+"  "+".png");
//     file.save(new Bitmap(bd),"未命名.png");
   }

     
   private function startMove(event:Event):void{
    Sprite(tool).startDrag();  
       
   private function stopMove(event:Event):void{
    Sprite(tool).stopDrag();  
    

  
 ]]>
 </fx:Script>
 <fx:Declarations>
    <!--导航工具-->
  <esri:NavigationTool id="navTool" map="{map}"/>
  <mx:TraceTarget includeCategory="true"
      includeLevel="true"
      includeTime="true"
      level="{LogEventLevel.DEBUG}"/>
  </fx:Declarations>
      <esri:Map width="100%" height="100%" id="map" logoVisible="false" styleName="mapStyle">
     <esri:extent>
      <esri:Extent xmin="114" ymin="38" xmax="11600000" ymax="4200000"/>
     </esri:extent>
     <esri:ArcGISTiledMapServiceLayer
      url="http://www.arcgisonline.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer"/>
       </esri:Map>

     <s:BorderContainer id="tool" y="30"  height="30" alpha="0.7" mouseDown="startMove(event)" mouseUp="stopMove(event)">
  <s:HGroup>
    <s:Button  id="fd" height="30"   width="40" label="放大"  icon="{zoomin}"   click="tbb_changeHandler(event)" />
    <s:Button  id="sx" height="30"  width="40" label="缩小"    icon="{zoomout}" click="tbb_changeHandler(event)" />
       <s:Button id="py" height="30"  width="40" label="平移" icon="{pan}"  click="tbb_changeHandler(event)" />
       <s:Button  id="qt" height="30"  width="40" label="全图" icon="{fullmap}"  click="tbb_changeHandler(event)"  />
       <s:Button  width="40" height="30"  label="全屏" id="fullscreenbtn"  click="fullScreen()" />
       <s:Button id="querry" height="30"  width="40" label="查询"  click="tbb_changeHandler(event)"  />
       <s:Button  id="print" height="30"   width="40" label="打印"  click="tbb_changeHandler(event)"  />
  </s:HGroup>
       </s:BorderContainer>
</s:Application

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:38521次
    • 积分:516
    • 等级:
    • 排名:千里之外
    • 原创:2篇
    • 转载:70篇
    • 译文:0篇
    • 评论:0条
    文章分类