4 Replies Latest reply on Jul 16, 2006 5:56 PM by inlineblue

    Bindable

    mike2281 Level 1
      I have a custom mxml component that exposes a public property set accessor and I want to bind it to an instance class property.

      The bindable instace property is an ArrayCollection and the set accessor is called once at startup when the collections count is zero, then items are added to the collection via a web service but the set accessor is not called a second time so the custom control never gets populated.

      Before I switched to using a write only set accessor I had the property on the custom control markes as Bindable but this is not really necessary since the custom control will never alter the Array collection.

      Why is the set method only called once?

      Do both properties need to be marked [Bindable] if the compenent is for display only?

      When I mark the set accessor [Bindable] why do I get the following compiler warning?
      [Bindable] on write-only setter is unreachable and will be ignored.

      Thanks,

      Mike


        • 1. Re: Bindable
          mike2281 Level 1
          A shorter version of this question without getting to deep into [Bindable]

          On a custom accordian mxml control how do I fire an event when a Bindable property is set?

          [Bindable]
          public var modules:ICollectionView

          I need to call this.function when modules is set.
          public function onChange():void
          {
          this.removeAllChildren();
          for each (var m:Module in this.modules)
          {
          this.addChild(m.getManager());
          }
          }
          • 2. Re: Bindable
            inlineblue Level 1
            You're confusing the purpose of the Bindable tag. If a property is marked Bindable, it becomes a data source, not a destination. It makes no sense to mark a set-only property Bindable because you can't read from it (ie. can't be a source). So in your case, don't put the Bindable tag on the setter. Instead, put it on the source data object.

            And yes, if you need to take some action when a property is set, then use a setter as you have been. If you still have problems, then post some of your code and maybe we can help you.
            • 3. Re: Bindable
              mike2281 Level 1
              I understand that the component does not need to be marked bindable on the the data source. The problem seems to be that binding is happening before creationComplete in the application is called. I will try some of the other events on the Application.

              Is there an application lifecycle document that describes the order in which these events fire?
              • 4. Re: Bindable
                inlineblue Level 1
                True, if the source object is a known data source object type, then you don't need to label it Bindable.

                How're you creating the bindings? If you're doing it in MXML, then all the bindings should be in place by the time creationComplete occurs.