3 Replies Latest reply on Nov 28, 2006 2:12 PM by ntsiii

    Component, dataProvider

    Johannes07
      How would one bind the dataProvider of a component that is called through AS to a variable XX

      mycomp.dataProvider=XX
      NNN.addChild(mycomp)

      The above code works but successive changes in XX are not reflected in the presentation.

      Is it possible ?

        • 1. Re: Component, dataProvider
          ntsiii Level 3
          Declare a bindable instance("global") variable:
          [Bindable] var myDataProvider:ArrayCollection;

          Bind the ui to it:
          ... dataProvider="{myDataProvider}"

          When you set the varialble, anything bound to it will update:
          myDataProvider = XML(event.result).data;

          Tracy
          • 2. Re: Component, dataProvider
            Johannes07 Level 1
            I am aware of ="{myDataProvider}" this works fine a long as I use the <mx:....

            I am referring to the creation of the component using AS.

            private function yyyyy():void {
            var mycomp:PieChart = new PieChart();
            mycomp.dataProvider = myDataProvider;
            xxxxxx.addChild(chart1);

            I don't seem to be able to use mycomp.dataProvider = "{myDataProvider}" here and passing mycomp.dataProvider = myDataProvider works but changes are not reflected.

            Do you mean I should declare this variable in the component script ?
            • 3. Re: Component, dataProvider
              ntsiii Level 3
              You need the [Bindable] metadata tag before the myDataProvider declaration. And of course that variable declaration must be in the scope of the component instance.

              And no, you cannot use binding braces in AS.

              Tracy