Solved! Go to Solution.
protected function singleLineSearch_keyUpHandler(event:KeyboardEvent):void { addSharedData("esriGeocoderText", new ArrayCollection([singleLineSearch.geocoder.text])); } <components:GeocoderComponent id="singleLineSearch" width="230" height="28" includeInLayout="false" visible="false" keyUp="singleLineSearch_keyUpHandler(event)"/><viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:esri="http://www.esri.com/2008/ags" xmlns:viewer="com.esri.viewer.*" xmlns:components="com.esri.viewer.components.*" widgetConfigLoaded="init()"> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import com.esri.viewer.utils.Hashtable; import com.esri.viewer.AppEvent; private function sharedDataUpdated(event:AppEvent):void { if (event.data.key == "esriGeocoderText") { if (event.data.collection[0]){ singleLineSearch.geocoder.text = event.data.collection[0]; } } } private function sharedDataUpdated2(event:AppEvent):void { var dataTable:Hashtable = event.data as Hashtable; if (dataTable.containsKey("esriGeocoderText")) { var recAC:ArrayCollection = dataTable.find("esriGeocoderText") as ArrayCollection; for (var i:Number = 0; i < recAC.length; i++) { singleLineSearch.geocoder.text = recAC; } dataTable.remove("esriGeocoderText"); }else if(dataTable.containsKey("Deactivate_DrawTool")){ setMapAction(null, null, null, null); } } private function init():void { if (configXML){ var geocoderXML:XML = configXML.geocoder[0] || configXML.search[0]; const shouldEnableGeocoder:Boolean = geocoderXML && (geocoderXML.@visible[0] != "false"); if (shouldEnableGeocoder) { singleLineSearch.hostBaseWidget = this; singleLineSearch.includeInLayout = true; singleLineSearch.visible = true; } } AppEvent.addListener(AppEvent.DATA_PUBLISH, sharedDataUpdated); AppEvent.addListener(AppEvent.DATA_SENT, sharedDataUpdated2); fetchSharedData(); } ]]> </fx:Script> <viewer:WidgetTemplate id="wTemplate" width="275" height="120"> <components:GeocoderComponent id="singleLineSearch" width="230" height="28" includeInLayout="false" visible="false"/> </viewer:WidgetTemplate> </viewer:BaseWidget> protected function singleLineSearch_keyUpHandler(event:KeyboardEvent):void { addSharedData("esriGeocoderText", new ArrayCollection([singleLineSearch.geocoder.text])); } <components:GeocoderComponent id="singleLineSearch" width="230" height="28" includeInLayout="false" visible="false" keyUp="singleLineSearch_keyUpHandler(event)"/><viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:esri="http://www.esri.com/2008/ags" xmlns:viewer="com.esri.viewer.*" xmlns:components="com.esri.viewer.components.*" widgetConfigLoaded="init()"> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import com.esri.viewer.utils.Hashtable; import com.esri.viewer.AppEvent; private function sharedDataUpdated(event:AppEvent):void { if (event.data.key == "esriGeocoderText") { if (event.data.collection[0]){ singleLineSearch.geocoder.text = event.data.collection[0]; } } } private function sharedDataUpdated2(event:AppEvent):void { var dataTable:Hashtable = event.data as Hashtable; if (dataTable.containsKey("esriGeocoderText")) { var recAC:ArrayCollection = dataTable.find("esriGeocoderText") as ArrayCollection; for (var i:Number = 0; i < recAC.length; i++) { singleLineSearch.geocoder.text = recAC; } dataTable.remove("esriGeocoderText"); }else if(dataTable.containsKey("Deactivate_DrawTool")){ setMapAction(null, null, null, null); } } private function init():void { if (configXML){ var geocoderXML:XML = configXML.geocoder[0] || configXML.search[0]; const shouldEnableGeocoder:Boolean = geocoderXML && (geocoderXML.@visible[0] != "false"); if (shouldEnableGeocoder) { singleLineSearch.hostBaseWidget = this; singleLineSearch.includeInLayout = true; singleLineSearch.visible = true; } } AppEvent.addListener(AppEvent.DATA_PUBLISH, sharedDataUpdated); AppEvent.addListener(AppEvent.DATA_SENT, sharedDataUpdated2); fetchSharedData(); } ]]> </fx:Script> <viewer:WidgetTemplate id="wTemplate" width="275" height="120"> <components:GeocoderComponent id="singleLineSearch" width="230" height="28" includeInLayout="false" visible="false"/> </viewer:WidgetTemplate> </viewer:BaseWidget>