Select to view content in your preferred language

onItemRollOver - getting the Error #1009:

896
3
10-06-2010 10:35 AM
DorothyMortenson
Deactivated User
Hello,
I am migrating my application from 1.3 to 2.0; and from Flex 3 to Flash Builder 4.

My application:
1) Displays a map with dam locations
2) allows the user to pick a point and distance for a buffer
3) shows the results of which dams are within the buffer in a datagrid.

My revised application works, up until the user rolls over anything in the datagrid.
Then I get the error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at dams_v2/findGraphicByAttribute()
at dams_v2/onItemRollOver()
at dams_v2/__dg_itemRollOver()
...

It would seem that something is out of order, but I don't know what it is.

Thanks for any help.
Dorothy


/* ------------------------------------------------
On Item Rollover
---------------------------------------------- */ 
private function onItemRollOver( event:ListEvent ) : void
{
  var gr:Graphic = findGraphicByAttribute(event.itemRenderer.data)
  Alert.show("glow set up here")

  var glow:Glow = new Glow(gr);
  Alert.show("glow set up here2")
  glow.duration = 1000 ;
  glow.alphaFrom = 1 ;
  glow.alphaTo = 0 ;
  glow.blurXFrom = 20 ;
  glow.blurXTo = 0 ;
  glow.blurYFrom = 30 ;
  glow.blurYTo = 0 ;
  glow.strength = 40;
  glow.color = 0xFFFF33;
 
  glow.play(); 
}

/* ------------------------------------------------
On Item Click
---------------------------------------------- */
private function onItemClick(event:ListEvent) : void
{
  var graphic:Geometry = findGraphicByAttribute(event.itemRenderer.data).geometry;
  var gr: Graphic = findGraphicByAttribute(event.itemRenderer.data)
  var graphicExtent:Extent;
  var grPt:MapPoint;
  var testIndex:String = event.columnIndex.toString();
 
  if (testIndex == "5")
  {
   //Center & Zoom to selected feature   
   grPt = MapPoint(graphic);
   Map.centerAt(grPt);
   Map.scale = 10000;
  }
 
  //Temporarily highlight selected graphic symbol
  gr.symbol = highlightedSymbol;
}

/* ------------------------------------------------
Find Graphics by Attribute
---------------------------------------------- */
public function findGraphicByAttribute(attributes:Object):Graphic
{
  for each(var graphic:Graphic in graphicsLayer.graphicProvider)
  {
      trace("att:" + graphic.attributes["damname"] );
      if (graphic.attributes["damname"] == attributes["damname"])
      {
          return graphic;
      }
  }  
  return null;
}
Tags (2)
0 Kudos
3 Replies
DasaPaddock
Esri Regular Contributor
What's the code on line 284?
0 Kudos
DorothyMortenson
Deactivated User
if (graphic.attributes["damname"] == attributes["damname"])

within the function:
/* ------------------------------------------------
Find Graphics by Attribute
---------------------------------------------- */
public function findGraphicByAttribute(attributes:Object):Graphic
{
  Alert.show("made it to start findGraphicByAttribute.")
  for each(var graphic:Graphic in graphicsLayer.graphicProvider)
  {
     // trace("att:" + graphic.attributes["damname"] );
      if (graphic.attributes["damname"] == attributes["damname"])
      {
          return graphic;
      }
  }  
  return null;
}
0 Kudos
DorothyMortenson
Deactivated User
I changed the code to be:

if (graphic.attributes == attributes)

And it is now working.
0 Kudos