5 Replies Latest reply on May 27, 2009 8:35 AM by ftosello

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


      Hi guys,


      I'm currently developing a Flex 3 Application.

      I've got an accordion, with two canvas:

      • first canvas (the accordion's default selected one) contains an Advanced Data Grid Column (with an XML feed data provider) which calls the function "clarity_itemClick(event)" on an itemClick.
      • the second canvas contains a custom component (ClarityActionDetail.mxml)

      The function called on the itemClick is the following:


      private function showClarityDetail(event:ListEvent): void {


           clarityDetail.dataClarity = event.itemRenderer.data;










      clarityDetail is the id of my custom component, and dataClarity is a variable present in my custom component.


      When I click on an item of my data grid for the first time, the debugger shows the following error:


      TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at components::ClarityAllActions/showClarityDetail()[C:\workspaces\Clarity\TODO\flex_src\com ponents\ClarityAllActions.mxml:67]
        at components::ClarityAllActions/clarity_itemClick()[C:\workspaces\Clarity\TODO\flex_src\com ponents\ClarityAllActions.mxml:71]
        at components::ClarityAllActions/__clarityGrid_itemClick()[C:\workspaces\Clarity\TODO\flex_s rc\components\ClarityAllActions.mxml:77]
        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::AdvancedListBase/mouseClickHandler()[C:\work\flex\dmv_automation \projects\datavisualisation\src\mx\controls\listClasses\AdvancedListBase.as:8270]
        at mx.controls::AdvancedDataGrid/mouseClickHandler()[C:\work\flex\dmv_automation\projects\da tavisualisation\src\mx\controls\AdvancedDataGrid.as:8422]


      (Line 67 corresponds to "clarityDetail.dataClarity = event.itemRenderer.data;"


      The second time I click on an item, the second accordion opens, and the custom component is loaded with the correct data (=dataClarity).


      I don't know how the fix this issue and any help would be greatly appreciated. While searching on forums and how-to's , I read about an eventlistener on ADDED_TO_STAGE but didn't manage to understand how to implement this in my code.