3 Replies Latest reply on Jan 25, 2010 10:35 AM by Gregory Lafrance

    error 1009

    GeorgeWS Level 1

      I have an error when my app loads but it works perfectly.

      This is the part I get an error with:

       

      [

      Bindable] private var myVarietals:ArrayCollection=new ArrayCollection;

       

       

      public function doPrompt(event:ResultEvent):void {

      myVarietals = qVarietals.Varietals.lastResult;

       

      var prompt:Object = new Object();

       

      prompt.data = 0;

      prompt.label =

      "Select Varietal";

       

      myVarietals.addItemAt( prompt, 0 );

      varietalfilter.selectedIndex = 0;

      }

       

      This is the error:

       

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at YMCO/doPrompt()[C:\Users\George\Desktop\Flex Builder 3\YMCO\src\YMCO.mxml:51]

      ...

       

      How can I get rid of the error?

       

      Thanks

       

      George

        • 1. Re: error 1009
          Gregory Lafrance Level 6

          What is the exact line of code at line 51 causing the error?

          • 2. Re: error 1009
            GeorgeWS Level 1

            This is my statement:

             

            [

             

            Bindable] private var myVarietals:ArrayCollection=new ArrayCollection;

             

             

            public function doPrompt(event:ResultEvent):void {

            myVarietals = qVarietals.Varietals.lastResult;

             

            var prompt:Object = new Object();

             

            prompt.data = 0;

            prompt.label =

            "Select Varietal";

             

            myVarietals.addItemAt( prompt, 0 );

            varietalfilter.selectedIndex = 0;

            }

             

             

            The last line is 51.

             

            Thanks

            • 3. Re: error 1009
              Gregory Lafrance Level 6

              So is the line of code causing the error:

               

              varietalfilter.selectedIndex = 0;

               

              What is varietalfilter and how is it instantiated? If it has been declared but not initialized then that is one possibility.

               

              You might be able to do this:

               

              if(varietalfilter != null){

                  varietalfilter.selectedIndex = 0;

              }

               

              but you are probably better off finding the real source of the issue.

               

              If this post answers your question or helps, please mark it as such.


              Greg Lafrance - Flex 2 and 3 ACE certified

              www.ChikaraDev.com

              Flex / AIR Development, Training, and Support Services