Select to view content in your preferred language

"esriFieldTypeInteger" not found

905
5
02-22-2012 07:40 AM
JamesMoon
Emerging Contributor
Hello!

Might someone know the reason for the error below?

Jim

ReferenceError: Error #1069: Property (com.esri.ags.layers.supportClasses::Field)#0
  alias = (null)
  domain = (null)
  editable = false
  length = 8
  name = "BZONE"
  type = "esriFieldTypeInteger" not found on builtin.as$0.MethodClosure and there is no default value.
at Control/getBzoneDataFields()

FlexBuilder 4 Plugin for Eclipse
ArcGIS Flex API 2.5

Code:

var field:Field  = new Field;
var fields:Array = [];  
field.name = 'BZONE';
field.type = Field.TYPE_INTEGER;
field.length = 8;
fields.push[field];       // line 698
Tags (2)
0 Kudos
5 Replies
IvanBespalov
Frequent Contributor
James,
may be bacause

Field.TYPE_INTEGER is Long Integer
TYPE_INTEGER Constant 
public static const TYPE_INTEGER:String = esriFieldTypeInteger
Long Integer.


and

Filed.TYPE_SMALL_INTEGER is Integer
TYPE_SMALL_INTEGER Constant 
public static const TYPE_SMALL_INTEGER:String = esriFieldTypeSmallInteger
Integer.


http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/supportClasses/Field.html#TYPE_INTE...
0 Kudos
JamesMoon
Emerging Contributor
Thank you for your response, Ivan.

I understand the two types. What I do not understand why my attempt to utilize Field.TYPE_INTEGER results in the error:

"esriFieldTypeInteger" not found on builtin.as$0.MethodClosure and there is no default value.

or why changing TYPE_INTEGER to TYPE_SMALL_INTEGER results in:

"esriFieldTypeSmallInteger" not found on builtin.as$0.MethodClosure and there is no default value.

Regards,
Jim
0 Kudos
IvanBespalov
Frequent Contributor
Seems like all right...

fields.push(field);


I have no ideas...
0 Kudos
IvanBespalov
Frequent Contributor
Can you show your code?

I could not get an error.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark" 
      xmlns:mx="library://ns.adobe.com/flex/mx">
 <!-- Adobe FLEX SDK ver. 4.5.1 -->
        <!-- ArcGIS API for FLEX ver. 2.5 -->
 <s:layout>
  <s:VerticalLayout gap="10"
        paddingBottom="10"
        paddingLeft="10"
        paddingRight="10"
        paddingTop="10" />
 </s:layout>
 
 <fx:Script>
  <![CDATA[
   import com.esri.ags.layers.supportClasses.Field;
   
   import mx.collections.ArrayCollection;
  
   private var arrFields:Array = new Array();
   
   [Bindable]
   private var gridSource:ArrayCollection = new ArrayCollection();
   
   protected function onDateFieldAdd(event:MouseEvent):void
   {
    var name:String = getRandomString(6);
    var alias:String = getRandomString(7);
    var field:Field = createField(name, Field.TYPE_DATE, alias, 10);
    
    arrFields.push(field);
    gridSource = new ArrayCollection(arrFields);
   }

   protected function onDoubleFieldAdd(event:MouseEvent):void
   {
    var name:String = getRandomString(6);
    var alias:String = getRandomString(7);
    var field:Field = createField(name, Field.TYPE_DOUBLE, alias);
    
    arrFields.push(field);
    gridSource = new ArrayCollection(arrFields);
   }


   protected function onGeometryFieldAdd(event:MouseEvent):void
   {
    var name:String = getRandomString(6);
    var alias:String = getRandomString(7);
    var field:Field = createField(name, Field.TYPE_GEOMETRY, alias);
    
    arrFields.push(field);
    gridSource = new ArrayCollection(arrFields);
   }


   protected function onLongFieldAdd(event:MouseEvent):void
   {
    var name:String = getRandomString(6);
    var alias:String = getRandomString(7);
    var field:Field = createField(name, Field.TYPE_INTEGER, alias, 8);
    
    arrFields.push(field);
    gridSource = new ArrayCollection(arrFields);
   }


   protected function onIntFiledAdd(event:MouseEvent):void
   {
    var name:String = getRandomString(6);
    var alias:String = getRandomString(7);
    var field:Field = createField(name, Field.TYPE_SMALL_INTEGER, alias, 4);
    
    arrFields.push(field);
    gridSource = new ArrayCollection(arrFields);
   }
   
   private function createField(fieldName:String, fieldType:String, fieldAlias:String = null, fieldLength:int = 0):Field
   {
    var result:Field = null;
    
    if (fieldName != null && fieldType != null)
    {
     result = new Field();
     result.name = fieldName;
     result.type = fieldType;
     result.alias = fieldAlias;
     if (fieldLength > 0)
     {
      result.length = fieldLength;
     }
    }
    
    return result;
   }
   
   private function getRandomString(length:Number):String{
    var a:String = "abcdefghijklmnopqrstuvwxyz";
    var alphabet:Array = a.split("");
    var randomString:String = "";
    for (var i:Number = 0; i < length; i++){
     randomString += alphabet[Math.floor(Math.random() * alphabet.length)];
    }
    return randomString;
   }

  ]]>
 </fx:Script>
 
 <mx:HDividedBox width="100%"
     height="100%">
  
  <s:Panel width="50%"
     height="100%">
   
   <s:layout>    
    <s:VerticalLayout gap="10" 
          paddingTop="10"
          paddingLeft="10"/>    
   </s:layout>
   
   <s:Button label="Add date field"
       click="onDateFieldAdd(event)" />
   
   <s:Button label="Add double field"
       click="onDoubleFieldAdd(event)" />
   
   <s:Button label="Add geometry field"
       click="onGeometryFieldAdd(event)" />
   
   <s:Button label="Add long field"
       click="onLongFieldAdd(event)" />
   
   <s:Button label="Add int field"
       click="onIntFiledAdd(event)" />
   
  </s:Panel>
  
  <s:Panel width="50%"
     height="100%">
   
   <s:DataGrid dataProvider="{gridSource}" 
      width="100%" 
      height="100%">
    
    <s:columns>
     <s:ArrayList>
      
      <s:GridColumn dataField="name" />
      
      <s:GridColumn dataField="alias" />
      
      <s:GridColumn dataField="type" />
      
      <s:GridColumn dataField="length" />
      
     </s:ArrayList>
    </s:columns>
    
   </s:DataGrid>
   
  </s:Panel>
  
 </mx:HDividedBox> 
 
</s:Application>
0 Kudos
JamesMoon
Emerging Contributor
Ivan,

Thank you for your persistence. Good eye:

fields.push(field);

Yes, that incorrect syntax was the problem.

Thanks again!

Jim
0 Kudos