Here is the full code for my example, I would like to change the background color of an infoSymbol, it works, but you have to drag the map around for the update to take effect. Is there a way to refresh the graphic after the style changes?Ideally I would like a way to dynamically change the background of one infoSymbol, currently it changes all infoSymbols defined with that containerStyleName.thanks,steve
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:esri="http://www.esri.com/2008/ags"
xmlns:s="library://ns.adobe.com/flex/spark"
pageTitle="Basic InfoSymbol example">
<fx:Style >
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
@namespace esri "http://www.esri.com/2008/ags";
.myStyle
{
backgroundColor: #FF0000;
border-color: #578DB8;
border-thickness: 2;
info-placement: bottomright;
}
</fx:Style>
<fx:Script>
<![CDATA[
import mx.core.FlexGlobals;
import mx.events.ColorPickerEvent;
protected function colorpicker1_changeHandler(event:ColorPickerEvent):void
{
// FlexGlobals.topLevelApplication.styleManager.getStyleDeclaration('.myStyle').setStyle('backgroundColor',event.currentTarget.selectedColor);
mygraphic.styleManager.getStyleDeclaration('.myStyle').setStyle('backgroundColor',event.currentTarget.selectedColor);
mygraphic.invalidateProperties(); // doesn't do anything
graphicslayer.refresh(); // doesn't do anything
graphicslayer.invalidateDisplayList(); // doesn't do anything
}
]]>
</fx:Script>
<fx:Declarations>
<esri:InfoSymbol id="infoSymbol1" containerStyleName="myStyle" >
<esri:infoRenderer >
<fx:Component>
<s:DataRenderer>
<s:Label text="Label 1" color="0xFEFEFE"/>
</s:DataRenderer>
</fx:Component>
</esri:infoRenderer>
</esri:InfoSymbol>
</fx:Declarations>
<esri:Map>
<esri:extent>
<esri:Extent xmin="-17526410" ymin="-6369184" xmax="3557" ymax="13433510">
<esri:SpatialReference wkid="102100"/>
</esri:Extent>
</esri:extent>
<esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
<esri:GraphicsLayer id="graphicslayer" symbol="{infoSymbol1}">
<esri:Graphic id="mygraphic">
<esri:geometry>
<esri:MapPoint x="-13057025" y="3912271"/>
</esri:geometry>
</esri:Graphic>
<esri:Graphic id="mygraphic2">
<esri:geometry>
<esri:MapPoint x="-12057025" y="3912271"/>
</esri:geometry>
</esri:Graphic>
</esri:GraphicsLayer>
</esri:Map>
<s:BorderContainer top="100" horizontalCenter="0" backgroundColor="0xffffff" >
<s:HGroup left="20" right="20" top="20" bottom="20" verticalAlign="middle" >
<s:Label text="Change color and move map to update" />
<mx:ColorPicker top="200" horizontalCenter="0" change="colorpicker1_changeHandler(event)" />
</s:HGroup>
</s:BorderContainer>
</s:Application>