3 Replies Latest reply on Apr 21, 2008 7:43 AM by misery_101

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

    misery_101
      I am getting a runtime error when I click a button that fires the addPerson function.
      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at main/addPerson()[C:\Documents and Settings\edunn\My Documents\Flex Builder 3\workspace2\Test-1\src\main.mxml:178]
      at main/___main_Button4_click()[C:\Documents and Settings\edunn\My Documents\Flex Builder 3\workspace2\Test-1\src\main.mxml:228]

      I am new to Action Script - and object programming - so understand...

      I do not understand what I have done wrong here...

      I have a result list coming from an external web service that populates in a datagrid. I'd like to be able to update that datagrid and then push back to the web service the new array.

      Any ideas?????

      import mx.rpc.events.ResultEvent;
      import mx.rpc.events.FaultEvent;
      import mx.collections.ArrayCollection;
      import generated.webservices.FxAppiaUserFeaturesService;
      import generated.webservices.UserSimRingConfig;
      import generated.webservices.SimRingType;

      public var plist:ArrayCollection

      //Updated Function to populate the data from WS
      public function retrieveUserSimRingConfig(e:ResultEvent):void {
      var UsrSimRngCfgNumList:Array = new UserSimRingConfig().simRingNumberList;
      var plist:ArrayCollection = e.result.simRingNumberList;
      dgSimPhoneList.dataProvider = plist;


      if (e.result.active) {
      chboxSimultaneousRingPhones.selected=true;
      } else {
      chboxSimultaneousRingPhones.selected=false;
      }

      if (e.result.simRingType == "NO_RING_WHILE_ONCALL") {
      chboxSimultaneousRing.selected=true;
      } else {
      chboxSimultaneousRing.selected = false;
      }

      }

      // Add a person to the ArrayCollection.
      public function addPerson():void {
      plist.addItem({simRingNumberList:txtPhoneNumber1.text});
      }

      I posted this in the General Section first by mistake...