4 Replies Latest reply on Oct 1, 2008 2:39 PM by Newsgroup_User

    ToggleButtonBar dataProvider

    Mayra999
      I have a ToggleButtonBar with it's dataProvider bound to an array. When I add items to the array, the toggleButtonBar does not update. I have to reset the dataProvider to the array. I have a bindable array:

      [Bindable] protected var myArray:Array = new Array();

      In mxml I bind it

      <mx:ToggleButtonBar dataProvider="{myArray}"/>

      and then in code I add things to the array.

      myArray.push('blah");

      Any thoughts?
        • 1. Re: ToggleButtonBar dataProvider
          theLoggerGuy
          Change your data source from an Array to an ArrayCollection and it should work.
          • 2. Re: ToggleButtonBar dataProvider
            Level 7

            "Mayra999" <webforumsuser@macromedia.com> wrote in message
            news:gbufb8$h0g$1@forums.macromedia.com...
            >I have a ToggleButtonBar with it's dataProvider bound to an array. When I
            >add
            > items to the array, the toggleButtonBar does not update. I have to reset
            > the
            > dataProvider to the array. I have a bindable array:
            >
            > [Bindable] protected var myArray:Array = new Array();
            >
            > In mxml I bind it
            >
            > <mx:ToggleButtonBar dataProvider="{myArray}"/>
            >
            > and then in code I add things to the array.
            >
            > myArray.push('blah");
            >
            > Any thoughts?

            This is the exact reason why the ArrayCollection class exists. Use that.


            • 3. Re: ToggleButtonBar dataProvider
              Mayra999 Level 1
              Wow, you are right, that was easy. I had originally had an ArrayCollection, but then it threw some exception saying it wanted an Array, so I switched it. Now its working just fine though, thanks!
              • 4. Re: ToggleButtonBar dataProvider
                Level 7

                "Mayra999" <webforumsuser@macromedia.com> wrote in message
                news:gc0q09$jvu$1@forums.macromedia.com...
                > Wow, you are right, that was easy. I had originally had an
                > ArrayCollection, but then it threw some exception saying it wanted an
                > Array, so I switched it. Now its working just fine though, thanks!

                You're welcome :-)