2 Replies Latest reply on Jun 21, 2009 1:43 AM by *Prashant Shelke*

    setting the selected index for a combobox populated by an arrayCollection

    markFuqua

      Ok...I think, after ___ days (too embarrased to admit how long I've been working on this), I think I might be close.  Here's the deal...

       

      I have a comboBox named constructionPh

      It is populated by an arrayCollection named acConstructionPhases

       

      That part is working.  Now I want to allow a user to edit a record...so I want to set the selectedIndex of this comboBox to equal the value of the row in the datagrid the user clicked.  So, I set the  itemClick="fillInForm(event)"

       

      Here is the code for fillInform function:

       

      private function fillInForm(event:Event):void {
                      openAddForm();
                      addEditItem.label = "Edit";
                      for (var i:int = 0; i < acConstructionPhases.length; i++) {

       

                       if (data.ConstructionPhase == acConstructionPhases[i].ConstructionPhaseId) {

       

                        ConstructionPh.selectedIndex = i;
                      break;
                   }

       

                  }
              }

       

      Now, when I run the app and click on a row on the datagrid, I get the following error message:

       

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
          at EstimateColdfusion/fillInForm()[C:\Documents and Settings\Winuser\My Documents\Flex Builder 3\Estimate\src\EstimateColdfusion.mxml:89]
          at EstimateColdfusion/__dg_itemClick()[C:\Documents and Settings\Winuser\My Documents\Flex Builder 3\Estimate\src\EstimateColdfusion.mxml:198]
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src \mx\core\UIComponent.as:9298]
          at mx.controls.listClasses::ListBase/mouseClickHandler()[C:\autobuild\3.2.0\frameworks\proje cts\framework\src\mx\controls\listClasses\ListBase.as:9040]

       

      I am having a helovatime wrapping my head around this stuff...I really thought I had it when FlexBuilder stopped giving me errors...but alas, not to be.  Any help would be greatly appreciated.

       

      Mark