Hi, I have created a polygon dynamically in my code behind. I am trying to add it into a graphics layer and show it on the map. Everything seems to be working ok as i step through, but the polygon is not displaying.the FPClass.PlotTrace method returns a polygon and the code is as follows:
public function PlotTrace():Polygon
{
firingPosX = parseInt(fpFirePoint.toString().substr(0,6));
firingPosY = parseInt(fpFirePoint.toString().substr(6,6));
//if a min range has been set, set up the slip bearings to change the plotting of the trace
if (minRange > 0)
{
//plot a slipped trace
}
if (hefLength > 0 && stdTraceLength == 0)
{
//plot a hef trace
}
else
{
myTrace = new Polygon();
myTrace.addRing(createFFAFiringPoint());
}
return myTrace;
}
createFFAFiringpoint returns an array of points used to create the polygon ring: myTrace shows in the debugger as follows:
myTrace com.esri.ags.geometry.Polygon (@106b9b79)
[inherited]
defaultSymbol com.esri.ags.symbol.SimpleFillSymbol (@10599d29)
extent <exception thrown by getter>
rings Array (@abb0ee9)
[0] Array (@1070d901)
[0] flash.geom.Point (@10580629)
length 717464.8361703869
x 382415 [0x5d5cf]
y 607054 [0x9434e]
[1] flash.geom.Point (@1055ce71)
length 717308.4317941585
x 382020.11968464445
y 607117.7929192365
[2] flash.geom.Point (@1065e629)
length 717425.8993229957
x 381281.23903104366
y 607720.7728738267
[3] flash.geom.Point (@10782fb1)
length 717649.1139426031
x 381252.6866894122
y 608002.1707483521
[4] flash.geom.Point (@10782fd9)
length 718632.3713444908
x 383550.0679880897
y 607718.5454554912
[5] flash.geom.Point (@10782241)
length 717728.7598126691
x 382810.00481118547
y 607117.0174510777
[6] flash.geom.Point (@10580629)
length 717464.8361703869
x 382415 [0x5d5cf]
y 607054 [0x9434e]
length 7
type "esriGeometryPolygon"
but the polygon doesn't appear on the map. i try to get the polygon from an instantiation of the FPClass, use it to create a graphic and then add the graphic to the graphics layer as follows:
private function PlotTrace(piTraceType:String):void
{
switch (piTraceType)
{
case ("FirePoint"):
{ if (vwHefStd.selectedChild.id=="StdTemplate")
{
var FPClass:FiringPointTrace = new FiringPointTrace(parseInt(txtFPCoord.text), parseInt(txtFPLeft.text), parseInt(txtFPRight.text), parseInt(txtStdLength.text),parseInt(txtStdWidth.text), parseInt(txtStdBSD.text), chkHT.selected,0,0,0,0,parseInt(txtStdAimErr.text), parseInt(txtFPMinRange.text))
var polyGeometry:Geometry = new Geometry() as Polygon;
polyGeometry = FPClass.PlotTrace();
graphic = new Graphic(polyGeometry,sfs_dashedoutline);
gfxTemplates.add(graphic);
}
//else do hef template
{
}
}
//case 2
//case 3
}
}
I have created gfxtemplates in the init method for the widget and added the layer to the map in the same routine. I must be missing something but im not sure what! hope someone can help??