<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:esri="http://www.esri.com/2008/ags">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
private function loadHandler():void
{
dynamicMap.addEventListener(FlexEvent.SHOW, onShow)
}
private function onShow(e:Event):void
{
Alert.show("Visible")
}
]]>
</mx:Script>
<mx:Canvas width="100%" height="100%">
<esri:Map>
<esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer"/>
<esri:ArcGISDynamicMapServiceLayer id="dynamicMap" visible="{chkBox.selected}" load="loadHandler();" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer"/>
</esri:Map>
<mx:CheckBox label="Layer visible" id="chkBox"/>
</mx:Canvas>
</mx:Application>
/** * event added by me to listen for a layer being turn off or on in the map * event for when a layers visibility has changed */ public static const LAYER_VISIBILITY_CHANGED:String = "layerVisibilityChanged";
SiteContainer.dispatchEvent(new AppEvent(AppEvent.LAYER_VISIBILITY_CHANGED, false, false, layer.name));
SiteContainer.dispatchEvent(new AppEvent(AppEvent.LAYER_VISIBILITY_CHANGED, false, false, event));
SiteContainer.addEventListener(AppEvent.LAYER_VISIBILITY_CHANGED, yourPopupFunction);