2 Replies Latest reply on Mar 25, 2009 3:09 AM by bluewaterfall

    Resetting components/null object reference error

    bluewaterfall Level 1
      I have a complex form. It is in fact an accordion containing different section which serve as search options, as selected by the user. I am posting a simplified version (the real one contains trees with checkboxes, loads xml, etc) here. Nevertheless, the problem is the same.

      While I can reset/clear every single component separately (an input text field, a numeric stepper, checkboxes), I can't seem to find a way to reset/clear all of them, with a single click.

      The error I get is

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at clearform/clearForm()[C:\Inetpub\wwwroot\myflex\src\clearform.mxml:43]
      at clearform/___clearform_Button5_click()[C:\Inetpub\wwwroot\myflex\src\clearform.mxml:101]

      This error appears once I try to reset/clear the whole "form" via a single button click.

      I am aware that the cause for this error is usually "component instantiation life cycle" or that "I am trying to reference something that isn't there yet."

      I have seen solutions for objects that have been created dynamically, via ActionScript. But how can I solve this when I created the whole interface in Flex Builder 3, using tags? I have many design and UI elements here and I really don't want to create everything via ActionScript code. Also, I can't use the <form> tag because this interface is way too complicated and has other non-standard elements like a tree with checkboxes.

      The error appears when I click the button for resetting all the elements - which calls the clearForm() function.

      How can I solve this? Any help is appreciated.