flex 界面改进

    技术2022-05-20  44

    f

     

     

    代码如下:

    <?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"  xmlns:ags="com.esri.ags.*"    xmlns:esri="http://www.esri.com/2008/ags"    xmlns:window="com.easy.window.*"    paddingLeft="10" paddingRight="10" paddingBottom="10"     layout="absolute"    initialize="loadIntParment();"    >    <mx:Script>   <![CDATA[    import mx.events.ItemClickEvent;   import mx.rpc.events.FaultEvent;   import mx.rpc.events.ResultEvent;   import mx.rpc.http.HTTPService;   import mx.controls.Alert;      import com.esri.ags.Map;   import com.esri.ags.events.MapEvent;   import com.esri.ags.toolbars.Draw;   import com.esri.ags.events.DrawEvent;      import com.esri.ags.layers.ArcGISTiledMapServiceLayer;   import com.esri.ags.layers.ArcGISDynamicMapServiceLayer;         var title:String;   var subtitle:String;   var logo:String;   var configMap:Array = [];      private var map:Map;   private var drawToolbar:Draw;    //初始化参数   public function loadIntParment():void   {    configLoad();   }       //加载配置文件   private function configLoad():void   {    var configService:HTTPService = new HTTPService();    configService.url = "config.xml";    configService.resultFormat = "e4x";    configService.addEventListener(ResultEvent.RESULT, configResult);    configService.addEventListener(FaultEvent.FAULT, configFault);     configService.send();   }       //加载失败   private function configFault(event:mx.rpc.events.FaultEvent):void   {    var sInfo:String = "Error: ";    sInfo += "Event Target: " + event.target + "/n/n";    sInfo += "Event Type: " + event.type + "/n/n";    sInfo += "Fault Code: " + event.fault.faultCode + "/n/n";    sInfo += "Fault Info: " + event.fault.faultString;    Alert.show(sInfo);   }       //加载结果   private function configResult(event:ResultEvent):void   {    //转换XML文件对象    var configXML:XML = event.result as XML;    title = configXML..title;     subtitle = configXML..subtitle;    logo = configXML..logo;          var basemapList:XMLList = configXML.map.basemaps.mapservice;        for (var i = 0; i < basemapList.length(); i++)    {     var msLabel:String = basemapList[i].@label;     var msType:String = basemapList[i].@type;     var msVisible:Boolean = true;     if (basemapList[i].@visible == "false")      msVisible = false;      var msAlpha:Number = 1;     if (!isNaN(basemapList[i].@alpha))      msAlpha = Number(basemapList[i].@alpha);           var msURL:String = basemapList[i];     var mapservice:Object =      {      label: msLabel,      type: msType,      visible: msVisible,      alpha: msAlpha,      url: msURL     }     configMap.push(mapservice);    }            //开始加载地图    LaadMap();    //加载界面    LaadPage();           }           //加载地图   private function LaadMap():void      {             map = new Map();       map.id = "map";       map.setStyle("backgroundColor","#FFFAF0");       map.zoomSliderVisible = false;       this.addChild(map);                    for (var i = 0; i < configMap.length; i++)          {           var label:String  = configMap[i].label;           var type:String = configMap[i].type;           var url:String =  configMap[i].url;           var visible:Boolean = configMap[i].visible;           var alpha:Number = Number(configMap[i].alpha);                      switch (type.toLowerCase())     {      case "tiled":      {       var tiledlayer:ArcGISTiledMapServiceLayer = new ArcGISTiledMapServiceLayer(url);       tiledlayer.id = label;       tiledlayer.visible = visible;       tiledlayer.alpha = alpha;       map.addLayer(tiledlayer);       break;      }             case "dynamic":      {       var dynlayer:ArcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer(url);       dynlayer.id = label;       dynlayer.visible = visible;        dynlayer.alpha = alpha;       map.addLayer(dynlayer);       break;      }                 }               }                map.panArrowsVisible = false;       map.zoomSliderVisible = true;       map.logoVisible = false;      }           //加载页面   private function LaadPage(){                 }                   //切换菜单      private function clickHandler(event:ItemClickEvent):void {                    //关闭所有窗口          this.toc.mapContent.visible = false;          this.toc.mapContent.height = 0;          this.toc.mapContent2.visible = false;          this.toc.mapContent2.height = 0;          this.toc.mapContent3.visible = false;          this.toc.mapContent3.height = 0;          this.toc.mapContent4.visible = false;          this.toc.mapContent4.height = 0;                    if(event.index == 0){           this.toc.visible = true;     this.toc.mapContent.height = 230;     this.toc.mapContent.viewStack.selectedIndex = 1;     this.toc.mapContent.visible = true;          }                     if(event.index == 1){           this.toc.visible = true;     this.toc.mapContent2.height = 230;     this.toc.mapContent2.viewStack.selectedIndex = 1;     this.toc.mapContent2.visible = true;          }                               if(event.index == 2){           this.toc.visible = true;     this.toc.mapContent3.height = 230;     this.toc.mapContent3.viewStack.selectedIndex = 1;     this.toc.mapContent3.visible = true;          }                     if(event.index == 3){           this.toc.visible = true;     this.toc.mapContent4.height = 230;     this.toc.mapContent4.viewStack.selectedIndex = 1;     this.toc.mapContent4.visible = true;          }                                                            }                                                          ]]>    </mx:Script>        <ags:Map id="map" x="0" y="0" width="100%" height="100%"  left="0" top="0" backgroundColor="#FFFAF0">    <esri:ArcGISDynamicMapServiceLayer                id="myDynamicService"                url="http://localhost:8399/arcgis/rest/services/cl/MapServer"                load="myDynamicService.defaultVisibleLayers()"                                 />    </ags:Map>        <!-- logo --> <mx:Canvas y="10" width="90%" height="80" left="20" right="20" borderStyle="solid" cornerRadius="10" borderThickness="3" themeColor="#4189B6" backgroundAlpha="1.0" backgroundColor="#B60606" alpha="0.51">  <mx:Image source="@Embed('com/resoure/images/hui.png')" x="10" y="11"/>  <mx:Label text="消防应急救援GIS系统" width="450" fontFamily="Georgia" fontSize="22" color="#F7F9F9" fontWeight="bold" x="66" y="10"/>  <mx:HRule x="70" y="40" width="252" height="1" strokeColor="#FF0000" strokeWidth="20"/> <!-- 红线 -->  <mx:Label x="69" y="41" text="武汉达梦数据库有限公司消防应急事业部" color="#34EAEC" fontSize="14"/>        <mx:ToggleButtonBar right="40" y="25" fontSize="12" itemClick="clickHandler(event);">            <mx:dataProvider>                <mx:Array>                    <mx:String>功能菜单1</mx:String>                    <mx:String>功能菜单2</mx:String>                    <mx:String>功能菜单3</mx:String>                    <mx:String>功能菜单4</mx:String>                </mx:Array>            </mx:dataProvider>        </mx:ToggleButtonBar>   </mx:Canvas>               <!-- 工具条 --> <mx:ToggleButtonBar toggleOnClick="true" right="20" top="100"  fontSize="12">        <mx:dataProvider>         <mx:Object label="放大>         <mx:Object label="缩小>         <mx:Object label="后退>         <mx:Object label="前进>                         <mx:Object label="平面图>         <mx:Object label="影像图>         <mx:Object label="三维图>                              </mx:dataProvider> </mx:ToggleButtonBar>          <!-- 操作区 -->   <window:BodyControl id="toc" right="20" showEffect="{showTOC}" hideEffect="{hideTOC}" visible="true"/>     <!-- 左出右进效果 --> <mx:WipeLeft id="showTOC" /> <mx:WipeRight id="hideTOC" /> <mx:Image id="highlight" source="@Embed(source='com/resoure/swf/highlight.swf')" visible="true"/>          </mx:Application>


    最新回复(0)