5 Replies Latest reply on Jun 9, 2011 6:38 AM by UbuntuPenguin

    Data Binding Will Not Be Able....

    UbuntuPenguin Level 4

      I have a piece of code, and it throws the infamous "Databinding will not be able to detect..."  Here is the code, the warning is thrown at the TextInput declaration line.  I am assuming it has something to do with the way the vm creates components and adds event listeners but I am not sure.  My current work around is to change the includeInLayout and mouseChildren property, but that feels kind of hackish.  Any help is greatly appreciated.


                  public function get textString():String
                      return _textString;
                  private var _textString:String;
                  public function set textString( value:String ):void
                      _textString = value;
                      dispatchEvent( new Event("textStringChange"));
              <s:State name="INPUT_STATE" />
              <s:State name="VIEW_STATE" />
          <s:TextInput text="@{textString}" excludeFrom="INPUT_STATE"/>  //Warning is thrown here


      The warning is thrown at the TextInput

        • 1. Re: Data Binding Will Not Be Able....
          CleanCoder Level 2

          Im curious about the "@". Are you appending it to the textString or does it serve some other purpose?

          • 2. Re: Data Binding Will Not Be Able....
            EvyatarBH Level 3

            I'll go with the simplistic approach and ask why not defining textString as follows -



            public var textString:String


            There's probably a good reason, but you didn't mention it...

            Is it related to that "@" sign you added to the binding? What is the purpose of using it?

            (I know the previous responder asked the same question, but I also want to know... )

            • 3. Re: Data Binding Will Not Be Able....
              Jason Moore Level 1

              It looks like its related to the exclusion of the text box from the state. But I found by adding an ID to your text input box seemed to fix it for me..



                <s:TextInput  id="putyouridhere" text="@{textString}" excludeFrom="INPUT_STATE"/>


              To the other comments... the @ symbol implements two way binding. So changing the variable changes the text field and visa versa.  Try doing an experiment with two text input fields bound to a single public variable and type in to one of them. Then try it with and without the @ symbol.


              With the @ symbol both change as the value gets copied back to the variable, without it.. it dos'nt... in the past you had to use a change event.



              1 person found this helpful
              • 4. Re: Data Binding Will Not Be Able....
                _spoboyle Level 4

                I remember reading something somewhere that says that each components/variable involved in the 2-way data binding need an id so that the compiler has a reference to each. Obviously your String has an id it's variable name. But you still explictly need to set this on your component.


                Sorry I can't remember where i read it, it might have been adobe docs or even in "Flex in a week"

                1 person found this helpful
                • 5. Re: Data Binding Will Not Be Able....
                  UbuntuPenguin Level 4

                  Thanks Jason, I clicked "Correct Answer" on the wrong reply, but adding the id alleviated the problem.  I would be interested to know what is going on in the guts of the flashplayer and why the id makes such a difference.  Thanks again.