<!-- 監聽地圖縮放事件,顯示當前地圖比例尺 -->
<!-- Copyright (c) 2010-2011 《ArcGIS Server開發指南——基於Flex和.NET》練習代碼
完整的代碼工程可以從 http://www.geocommon.net 下載 -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="755" minHeight="600"
xmlns:esri="http://www.esri.com/2008/ags">
<fx:Script>
<![CDATA[
import com.esri.ags.events.ZoomEvent;
protected function zoomEndHandler(event:ZoomEvent):void
{
labelScale.text = "1 : " + numFormater.format(map.scale);
}
]]>
</fx:Script>
<fx:Declarations>
<mx:NumberFormatter id="numFormater" precision="0" />
</fx:Declarations>
<esri:Map id="map" width="100%" height="100%" zoomEnd="zoomEndHandler(event)">
<esri:ArcGISDynamicMapServiceLayer
url="http://localhost/ArcGIS/rest/services/USAMap/MapServer" />
</esri:Map>
<s:Label id="labelScale" top="20" horizontalCenter="0"
fontSize="16" fontWeight="bold" backgroundColor="#ffffff" />
</s:Application>