12 Replies Latest reply on Oct 26, 2016 9:05 PM by sathyag34744601

    Annoying error

    Zolotoj Level 3

      I am getting an error that it's hard ( at least for me) to understand:

      Trace:

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
          at Function/<anonymous>()[E:\dev\hero_private\frameworks\projects\spark\src\spark\components \List.as:1398]
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at mx.core::UIComponent/dispatchEvent()[E:\dev\hero_private\frameworks\projects\framework\sr c\mx\core\UIComponent.as:13128]
          at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\hero_private\frameworks\project s\framework\src\mx\managers\LayoutManager.as:844]
          at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\hero_private\frameworks \projects\framework\src\mx\managers\LayoutManager.as:1180]
      Code with error:

      override mx_internal function dataProviderRefreshed():void
          {
              // At this point the dataProvider's contents have changed but the dataGroup's
              // item renderers have not.  If the caret item renderer is visible, find
              // its x,y "offset" relative to the dataGroup's position and then scroll
              // so that the new caret item renderer appears at the same offset.
             
              if ((caretItem !== undefined) && dataGroup && dataGroup.dataProvider)
              {
                  const newCaretIndex:int = dataGroup.dataProvider.getItemIndex(caretItem);
                  const caretItemRenderer:IVisualElement = dataGroup.getElementAt(caretIndex);
                 
                  if ((newCaretIndex != -1) && dataGroup.isElementVisible(caretItemRenderer))
                  {
                      const caretItemRendererX:Number = caretItemRenderer.getLayoutBoundsX();
                      const caretItemRendererY:Number = caretItemRenderer.getLayoutBoundsY();
                 
                      const caretOffsetX:Number = caretItemRendererX - dataGroup.horizontalScrollPosition;
                      const caretOffsetY:Number = caretItemRendererY - dataGroup.verticalScrollPosition;
                     
                      // Wait for updateComplete before updating the scroll position to ensure
                      // newCaretIndex is visible, so that other listeners/parts have completed
                      // their responses to the refresh event.
                     
                      const updateCompleteListenerA:Function = function():void {
                         dataGroup.removeEventListener(FlexEvent.UPDATE_COMPLETE, updateCompleteListenerA); // Error line
                          ensureCaretVisibility(newCaretIndex);
                          dataGroup.addEventListener(FlexEvent.UPDATE_COMPLETE, updateCompleteListenerB);                   
                         
                      };

       

                      // Wait for updateComplete before making the final update to the scroll position 
                      // so that layout bounds for the caret item renderer will have been computed.
                     
                      const updateCompleteListenerB:Function = function():void {
                          dataGroup.removeEventListener(FlexEvent.UPDATE_COMPLETE, updateCompleteListenerB);                   
                          restoreCaretScrollPosition(newCaretIndex, caretOffsetX, caretOffsetY);
                      };
                     
                      dataGroup.addEventListener(FlexEvent.UPDATE_COMPLETE, updateCompleteListenerA);
                     
                      return;
                  }
              }

      Code that triggers the error:

      ArrayCollection(dataProvider).refresh();

      This is a custom DropDownList which  implements IGridItemRenderer.

       

      Thanks for help.