Original User: kenbujaTo solve the multiple popup windows problem, I changed the testing code
//PopUp Window on DataGrid
var obj:Object = featureSet.attributes;
var myfloatdg:MyFloatDG;
myfloatdg = MyFloatDG(PopUpManager.createPopUp(myMap,MyFloatDG,false));
PopUpManager.centerPopUp(myfloatdg);
to this:
//PopUp Window on DataGrid
var obj:Object = featureSet.attributes;
// var myfloatdg:MyFloatDG;
if (myfloatdg == null)
{
myfloatdg = MyFloatDG(PopUpManager.createPopUp(myMap,MyFloatDG,false));
}
myfloatdg.visible = true;
PopUpManager.centerPopUp(myfloatdg);
For the datagrid interaction, you didn't include any functions to operate the ItemRollOver and ItemRollOut events for the datagrid. These are the changes I made to your code (which includes a change in the closeMe function to deal with the multiple popup problem)
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx= "http://www.adobe.com/2006/mxml"
xmlns:esri= "http://www.esri.com/2008/ags"
layout= "absolute"
width= "622"
height= "300"
showCloseButton= "true"
title= "Results"
close= "closeMe()">
<mx:Script>
<![CDATA[
import mx.events.ListEvent;
import com.esri.ags.geometry.Extent;
import com.esri.ags.layers.GraphicsLayer;
import com.esri.ags.Map;
import mx.managers.PopUpManager;
import com.esri.ags.Graphic;
[Bindable] public var myMap:Map;
[Bindable] public var myGraphicsLayer:GraphicsLayer;
private var _data:Object;
public function set graphicslayer(value:GraphicsLayer):void
{
myGraphicsLayer = value;
}
public function set dProvider(value:Object):void
{
_data = value;
resultsGrid.dataProvider = _data;
}
public function closeMe():void
{
this.visible = false;
myGraphicsLayer.clear();
}
private function onItemRollOver(event:ListEvent):void
{
findGraphicByAttribute(event.itemRenderer.data).symbol = highlightSymbol;
}
private function onItemRollOut(event:ListEvent): void
{
findGraphicByAttribute(event.itemRenderer.data).symbol = resultsSymbol;
}
private function findGraphicByAttribute( attributes : Object ) : Graphic
{
for each (var graphic:Graphic in myGraphicsLayer.graphicProvider)
{
if (graphic.attributes == attributes)
{
return graphic;
}
}
return null;
}
]]>
</mx:Script>
<esri:SimpleFillSymbol id="resultsSymbol" color="0x999999" alpha="0.01" style="solid">
<esri:SimpleLineSymbol color="0x00FFFF" width="2" alpha="1" style="solid" />
</esri:SimpleFillSymbol>
<esri:SimpleFillSymbol id="highlightSymbol" color="0xFF0000" alpha="1" style="cross">
<esri:SimpleLineSymbol color="0x00FFFF" width="2" alpha="1" style="solid" />
</esri:SimpleFillSymbol>
<mx:DataGrid id="resultsGrid"
itemRollOver="onItemRollOver(event);" itemRollOut="onItemRollOut(event);"
scroll="true" width="100%" height="40%">
<mx:columns>
<mx:DataGridColumn id="dcg" dataField="STATE_NAME"/>
<mx:DataGridColumn id="dcg1" dataField="POP2007"/>
</mx:columns>
</mx:DataGrid>
</mx:TitleWindow>