var results:ArrayCollection = new ArrayCollection;
function onResult(featureSet:FeatureSet, token:Object = null):void
{
if (featureSet.features.length > 0)
{
for each (var myGraphic3:Graphic in featureSet.features)
{
//Adds a mouseover event for the graphic
myGraphic3.addEventListener( MouseEvent.MOUSE_OVER, onMouseOver );
myGraphic3.addEventListener( MouseEvent.MOUSE_OUT, onMouseOut );
myGraphic3.symbol = resultsSymbol;
myGraphicsLayer.add(myGraphic3);
results.addItem(myGraphic3.attributes);
map.addLayer(myGraphicsLayer);
dg.visible = true;
dg.dataProvider = results;
function onMouseOver( event : MouseEvent ) : void
{
var graphic : Graphic = Graphic( event.target );
graphic.symbol = highlightSymbol;
for each( var attributes : Object in dg.dataProvider )
{
if (attributes === graphic.attributes)
{
dg.selectedIndex = (dg.dataProvider as ArrayCollection).getItemIndex(attributes)
}
}
dg.scrollToIndex(dg.selectedIndex);
}
function onMouseOut( event : MouseEvent ) : void
{
Graphic( event.target ).symbol = resultsSymbol;
dg.selectedIndex = -1;
}
function onItemRollOver( event : ListEvent ) : void
{
findGraphicByAttribute(event.itemRenderer.data).symbol = highlightSymbol;
}
function onItemRollOut( event : ListEvent ) : void
{
findGraphicByAttribute(event.itemRenderer.data).symbol = resultsSymbol;
}
function findGraphicByAttribute( attributes : Object ) : Graphic
{
for each (var graphic:Graphic in myGraphicsLayer.graphicProvider)
{
if (graphic.attributes == attributes)
{
return graphic;
}
}
return null;
}
}
}
var newDG:DataGrid = new DataGrid;
newDG.dataProvider = resultsArray;
newDG.addEventListener(ListEvent.ITEM_CLICK, newDG_ItemRollOver, false, 0, true);
newDG.addEventListener(ListEvent.ITEM_ROLL_OUT, newDG_ItemRollOut, false, 0 ,true);
newDG.addEventListener(ListEvent.ITEM_ROLL_OVER, newDG_ItemRollOver, false, 0, true);
protected function newDG_ItemRollOut(event:ListEvent):void
{
graphicLayer.clear();
}
protected function newDG_ItemRollOver(event:ListEvent):void
{
var highlightedGraphic:Graphic = findGraphicByAttribute(event.itemRenderer.data);
var glowFill:SimpleFillSymbol = new SimpleFillSymbol;
var glower:AnimateFilter = new AnimateFilter(highlightedGraphic,glow);
glower.motionPaths = kf;
glower.duration = 500;
glower.play();
}
protected function findGraphicByAttribute(attributes:Object):Graphic
{
for each (var graphic:Graphic in graphicsLayer.graphicProvider)
{
if (graphic.attributes == attributes)
{
return graphic;
}
}
return null;
}
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:GlowFilter id="glow" blurX="20" blurY="20" alpha="1" strength="100" color="0xff0000"/>
<fx:Vector id="kf" type="spark.effects.animation.MotionPath">
<s:SimpleMotionPath id="smpAlpha" property="alpha" valueFrom="1" valueTo="0"/>
<s:SimpleMotionPath id="smpBlurX" property="blurX" valueFrom="20" valueTo="0"/>
<s:SimpleMotionPath id="smpBlurY" property="blurY" valueFrom="20" valueTo="0"/>
</fx:Vector>
</fx:Declarations>
//Creates graphic for each point, adds attribute data for each point to array
var results:ArrayCollection = new ArrayCollection;
function onResult(featureSet:FeatureSet, token:Object = null):void
{
if (featureSet.features.length > 0)
{
for each (var myGraphic3:Graphic in featureSet.features)
{
//Adds a mouseover event for the graphic
myGraphic3.addEventListener( MouseEvent.MOUSE_OVER, onMouseOver );
myGraphic3.addEventListener( MouseEvent.MOUSE_OUT, onMouseOut );
myGraphic3.symbol = resultsSymbol;
myGraphicsLayer.add(myGraphic3);
results.addItem(myGraphic3.attributes);
map.addLayer(myGraphicsLayer);
dg.visible = true;
dg.dataProvider = results;
function onMouseOver( event : MouseEvent ) : void
{
var graphic : Graphic = Graphic( event.target );
graphic.symbol = highlightSymbol;
for each( var attributes : Object in dg.dataProvider )
{
if (attributes === graphic.attributes)
{
dg.selectedIndex = (dg.dataProvider as ArrayCollection).getItemIndex(attributes)
}
}
dg.scrollToIndex(dg.selectedIndex);
}
function onMouseOut( event : MouseEvent ) : void
{
Graphic( event.target ).symbol = resultsSymbol;
dg.selectedIndex = -1;
}
function dg_ItemRollOut(event:ListEvent):void
{
findGraphicByAttribute(event.itemRenderer.data).symbol = resultsSymbol;
}
function dg_ItemRollOver(event:ListEvent):void
{
findGraphicByAttribute(event.itemRenderer.data).symbol = highlightSymbol;
}
function findGraphicByAttribute(attributes:Object):Graphic
{
for each (var graphic:Graphic in myGraphicsLayer.graphicProvider)
{
if (graphic.attributes == attributes)
{
return graphic;
}
}
return null;
}
}
}