4 Replies Latest reply on Jun 25, 2011 6:53 AM by RBC

    Data Binding vs. Square Bracket Operator

    RBC Level 1

      I am new to flex and I am getting the dreaded message "Description Resource Path Location Type

      Data binding will not be able to detect changes when using square bracket operator.  For Array, please use ArrayCollection.getItemAt() instead.."  I would take this advice if I only knew how.  I tried...

       

      Here is the offending textArea code:

       

      <s:TextArea id="client_last_name" x="105" y="30" width="205" height="28"

      text="@{getThisCustomerResult.lastResult[0].client_last_name}"/>0

       

      And this is the function from which I drawing the data down:

      protected function getThisCustomer(itemID:Number):void

      {

      getThisCustomerResult.token = getToolBeltData.getThisCustomer(itemID);

      }

       

      If its important, the data is being pulled via ColdFusion CFC  using data/services from Flash Builder.

       

      Thank you.

        • 1. Re: Data Binding vs. Square Bracket Operator
          Flex harUI Adobe Employee

          Assuming lastResult is an ArrayCollection, it would be:

           

               

          text="@{ArrayCollect(getThisCustomerResult.lastResult).getItemAt(0).client_l

          ast_name}"

          1 person found this helpful
          • 2. Re: Data Binding vs. Square Bracket Operator
            RBC Level 1

            Thank you for the help...unfortunately, I get this error:

            Description Resource Path Location Type

            1180: Call to a possibly undefined method ArrayCollect

             

            So I guess it isn't an array collection, but judging by the original error message about the square brackets, it seems like Flex wants it to be.  Is there something I do to convert it to an array collection?  Sorry if I am dense...

             

             

            • 3. Re: Data Binding vs. Square Bracket Operator
              Flex harUI Adobe Employee

              You probably just have to

                  import mx.collections.ArrayCollection;

               

              In a script block.  You'll get a runtime error if the result isn't an

              ArrayCollection

              • 4. Re: Data Binding vs. Square Bracket Operator
                RBC Level 1

                Thanks a million for the help.  That was the issue.

                I want to note for someone reading this in the future that there was a slight typo (I think that's the problem) in the initial helpful answer--Instead of

                 

                text="@{ArrayCollect(getThisCustomerResult.lastResult).getItemAt(0).cl ient_l

                ast_name}"

                 

                I think you have to write out ArrayCollect so that it is ArrayCollection or it won't work and you'll get an error.    So it should be:

                 

                text="@{ArrayCollection(getThisCustomerResult.lastResult).getItemAt(0).cl ient_l

                 

                ast_name}"

                 

                Once again, sincere thanks for helping me.