5 Replies Latest reply on Apr 28, 2009 10:46 AM by snowscreen

    [Bindable] var userObj:Object not bindable?

    snowscreen

      When I pass an [bindable] Object to a custom component, and then later, in this component change values of this object - why do theese not get updated in my main-application?

      thanks in advance for a helping answer on this stupid question,

      snowscreen

        • 1. Re: [Bindable] var userObj:Object not bindable?
          Barna Biro Level 3

          Hi snowscreen,

           

          Are you using the variable defined in the custom component the way it is in the main component? Or are you passing a reference to it in the main component, another bindable variable that you are using on the main component. If that's the case then it won't work because binding doesn't work like that. It's not cool to use binding that way, instead, you should use custom events to signal application change.

           

          You should dispatch an event from the custom component and listen for it in the main application ( where the component is defined ). Once the event is dispatched ( with maybe additional data that you set in the custom component ) and is recieved in the main application, you can react to it accordingly. You should really avoid the use of Binding in such situations because it will only cause you headaches and a lot of wasted time.

           

          Best regards,

          Barna Biro

          1 person found this helpful
          • 2. Re: [Bindable] var userObj:Object not bindable?
            Michael Borbor Level 4

            Because in the flex sdk 3.x there isn't a two way binding but that 

            will change in the flex sdk 4.x

             

            Sincerely,

             

            Michael

             

            El 27/04/2009, a las 13:19, snowscreen <forums@adobe.com> escribió:

             

            >

            When I pass an Object to a custom component, and then 

            later, in this component change values of this object - why do 

            theese not get updated in my main-application?

            thanks in advance for a helping answer on this stupid question,

            snowscreen

            >

            1 person found this helpful
            • 3. Re: [Bindable] var userObj:Object not bindable?
              Barna Biro Level 3

              ^ Yes, that's the more "scientific explanation" Still, 2 way binding has advantages in some situations but it should not be abused of when more simple and efficient solutions can be easily implemented. Good luck.

              • 4. Re: [Bindable] var userObj:Object not bindable?
                ntsiii Level 3

                Also, Object is simply not bindable.  It does not posess sufficient type information for the compiler to build the event infrastructure necessary for binding.  ObjectProxy can be used to wrap Object for binding.  A better soultion is to use a typed component.

                 

                Similarly, Array and XMLList is not bindable.  ArrayCollection and XMLListCollection are provided to address this.

                 

                XML *is* bindable, through some compiler trickery.

                 

                Tracy Spratt

                • 5. Re: [Bindable] var userObj:Object not bindable? - solved, thanks
                  snowscreen Level 1

                  Thanks for all theese quick answers,

                  it's always good when you can continue coding without loosing too much time on such an issue.

                   

                  I will try to solve it with an event-like way.

                   

                  Thought so, that Objects arn't bindable,

                  glad too hear, that Gumbo will change this,

                  nice to hear the "correct" answer ntsiii and Michael Borbor,

                  and thanks to Barna Biro for a way to solve the prob.

                  snowscreen