I'm using a queryTask to define tooltips, graphic, listeners etc. I have an infoWindow that comes up when the user clicks a point. I'd like to be able to add a button within the infoWindow that zooms to the point when the user clicks that button.I've added a listener to the graphic:myGraphic.addEventListener("zoomHere",zoomHandler);
Then wrote the handler function: public function zoomHandler(event:MouseEvent): void {
var newMapPoint:MapPoint = MapPoint(lastGraphic.geometry);
if (mainMap.scale > 100000)
{
mainMap.scale = 100000;
} else {
var zoomScale:Number = mainMap.scale / 4;
mainMap.scale = zoomScale;
}
mainMap.centerAt( newMapPoint);
}
I'm not sure exactly how or where to call the click event. There isn't any error when I compile, but the event handler I created never gets called. So maybe I don't have the listener added to the right thing? I was able to add a listener to the whole Infow window using mainMap.infoWindow.addEventListener(MouseEvent.CLICK,zoomHandler), but I really only want the event on the button, not the whole infoWindow. <mx:Component className="MyInfoWindowRenderer" >
<mx:VBox verticalGap="-5" height="100%">
<infoClasses:InfoWindowLabel styleName="balloonTitle" text="{data.FACILITY}" width="100%"/>
<mx:Label text="{data.ADDRESS}" />
<mx:Label text="{data.CITY}"/>
<mx:Label includeInLayout="{data.PHONE1 != ''? true:false}"
visible="{data.PHONE1 != ''? true:false}" text="Phone: {data.PHONE1}"/>
<mx:Label includeInLayout="{data.PHONE2 != ''? true:false}"
visible="{data.PHONE2 != ''? true:false}"
text="Phone: {data.PHONE2}"/>
<mx:Label includeInLayout="{data.PHONE3_FB != ''? true:false}"
visible="{data.PHONE3_FB != ''? true:false}"
text="Phone: {data.PHONE3_FB}"/>
<!-- <mx:Label includeInLayout="{(data.PHONE1 == '' && data.PHONE2 == '') ? true:false}"
visible="{(data.PHONE1 == '' && data.PHONE2 == '') ? true:false}"
text="Phone: {data.PHONE3_FB}"/>
-->
<mx:Label includeInLayout="{data.DAYS != ''? true:false}"
visible="{data.DAYS != ''? true:false}"
text="---------------------------------------" />
<mx:Label includeInLayout="{data.DAYS != ''? true:false}"
visible="{data.DAYS != ''? true:false}"
text="{data.DAYS}"/>
<mx:Label includeInLayout="{data.HOURS != ''? true:false}"
visible="{data.HOURS != ''? true:false}"
text="{data.HOURS}"/>
<mx:Label includeInLayout="{data.CERTIFICATION != ''? true:false}"
visible="{data.CERTIFICATION != ''? true:false}" text="---------------------------------------" />
<mx:TextArea width="100%" height="60" fontSize="11" includeInLayout="{data.CERTIFICATION != ''? true:false}"
visible="{data.CERTIFICATION != ''? true:false}"
text="{data.CERTIFICATION}"/>
<mx:Label includeInLayout="{data.LOC_CODE != 'CENT'? false:true}"
visible = "{data.LOC_CODE != 'CENT'? false:true}"
text="** Location Approximate **"/>
<mx:Button label="Zoom Closer" id="btn_Zoom" >
<mx:click>
<![CDATA[
dispatchEvent(new Event("zoomHere", true));
]]>
</mx:click>
</mx:Button>
</mx:VBox>
</mx:Component>
The