Select to view content in your preferred language

map load error

1083
6
08-01-2011 02:34 AM
MarkHorsell
Emerging Contributor
I'm getting this error on the line in bold.



TypeError: Error #1009: Cannot access a property or method of a null object reference.

When i remove load="attrInsp.featureLayers = [points]" it does compile.



<esri:Map id="myMap" load="attrInsp.featureLayers = [points]" wrapAround180="true"
     mapClick="map_mapClickHandler(event)"
     openHandCursorVisible="false"
     x="{splitX}"
     width="{916-splitX}"
     height="398"
  
    

     >
 
 
  <esri:extent>
   <esri:Extent id="sheepfire"
       xmin="-13144000" ymin="4033000" xmax="-13066000" ymax="4099000">
    <esri:SpatialReference wkid="102100"/>
   </esri:Extent>
  </esri:extent>
 
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"  />

  <esri:FeatureLayer id="fireAreas"
         mode="selection"
         outFields="*"
       url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/2">
        </esri:FeatureLayer>


  <esri:FeatureLayer id="points"
         mode="selection"
         outFields="*"
         url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/0">
     
  </esri:FeatureLayer>
 
  <esri:GraphicsLayer id="myGraphicsLayer"  />

  <esri:infoWindowContent>
   <s:BorderContainer backgroundColor="0xFFFF00">
    <esri:AttributeInspector id="attrInsp"
           deleteFeature="attrInsp_deleteFeatureHandler(event)"
           updateFeature="attrInsp_updateFeatureHandler(event)">
    
     <esri:FieldInspector featureLayer="{points,fireAreas}"
           fieldName="description"
           label="ACTIVE_PRODUCTION"/>
    
     <esri:FieldInspector featureLayer="{points}"
           fieldName="type"
           label="FIELDNAME"/>
    
     <esri:FieldInspector featureLayer="{fireAreas}"
           fieldName="name"
           label="PRODUCTION_OIL">
      <esri:renderer>
       <fx:Component>
        <esri:ButtonBarField>
         <esri:dataProvider>
          <s:ArrayCollection>
           <fx:Object label="Yes" value="Yes"/>
           <fx:Object label="No" value="No"/>
          </s:ArrayCollection>
         </esri:dataProvider>
        </esri:ButtonBarField>
       </fx:Component>
      </esri:renderer>
     </esri:FieldInspector>
    </esri:AttributeInspector>
   </s:BorderContainer>
  </esri:infoWindowContent>

 
 
</esri:Map>
Tags (2)
0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus
Mark,

  When you use a variable in MXML for a property or attibute it has to be in curly braces.

{attrInsp.featureLayers = [points]}
0 Kudos
MarkHorsell
Emerging Contributor
Hi Robert,
Thanks very much for your time, in this case curly braces don't work. As yet I only have basic understanding of the API so have been looking at sample code and in this case im trying to replicate some of the functionality in the "AttributeInspectorInfoWindowEditable" sample as below. I'm using the same SWC 2.3.1 and a version 10 server.

From the sample code
  <esri:Map id="myMap"
              load="attrInsp.featureLayers = [myFeatureLayer]"
              mapClick="map_mapClickHandler(event)"
              openHandCursorVisible="false">

which does work.  I probably have omited something obvious, but have spent hours trying to work out what.
0 Kudos
BenFerguson
Occasional Contributor
You are actually doing an inline function there, so your syntax is ok.  I'm not seeing anything wrong with it.  I copied it into a blank project and got it to compile just fine.
0 Kudos
MarkHorsell
Emerging Contributor
I changed:

load="attrInsp.featureLayers = [points]"

to

load="onMapLoad(event)"

private function onMapLoad(p_evt:Event){

trace(attrInsp);//null??
trace(attrInsp.featureLayers);
        trace(points);
attrInsp.featureLayers =[points];
  
}

//TypeError: Error #1009: Cannot access a property or method of a null object reference.
 
The Attribute Inspector is null. Its as if the map load event fires before the layers are added.

http://help.arcgis.com/en/webapi/flex/apiref/index.html
0 Kudos
MarkHorsell
Emerging Contributor
Removed the onLoad and ran the same trace statements on mapClick.

Still can't find the attrInsp instance?
0 Kudos
MarkHorsell
Emerging Contributor
Now i've just taken the whole "AttributeInspectorInfoWindowEditable" wrapped it in Group instead of application and have just added it to stage. But it doesnt render at all. My thinking is that this is just not possible using the API.
0 Kudos