6 Replies Latest reply on Sep 9, 2008 1:45 PM by wyattbiker

    Why doesn repeater work inTileList?

    wyattbiker Level 1
      I have an array of the 50 states names. I want to use a repeater to generate a button for each one. It doesn't work because what it doesn it places the buttonson top of each other in the top left cornr of the application.

      However if I list them out one Button at a time (E.g. <mx:Button label="Alabama"/>)this works fine.
        • 1. Re: Why doesn repeater work inTileList?
          Level 7

          "wyattbiker" <webforumsuser@macromedia.com> wrote in message
          news:ga3mot$ap4$1@forums.macromedia.com...
          >I have an array of the 50 states names. I want to use a repeater to
          >generate a
          > button for each one. It doesn't work because what it doesn it places the
          > buttonson top of each other in the top left cornr of the application.
          >
          > However if I list them out one Button at a time (E.g. <mx:Button
          > label="Alabama"/>)this works fine.
          >
          >
          > <mx:TileList id="States" height="250" width="666"
          > maxColumns="5" rowHeight="50" columnWidth="50" x="21" y="20">
          > <mx:dataProvider>
          > <mx:Array>
          > <mx:Repeater id="rp" dataProvider="{stateNames}" >
          > <mx:Button label="{String(rp.currentItem)}"/>
          > </mx:Repeater>
          > </mx:Array>
          > </mx:dataProvider>
          > </mx:TileList>

          The first mistake you made is to put a Repeater tag within an Array. This
          whole code snippet doesn't make enough sense that I can figure out what
          you're trying to accomplish. Could you back up, regroup, and say from the
          beginning what you want to see in your TileList?

          -Amy


          • 2. Re: Why doesn repeater work inTileList?
            wyattbiker Level 1
            I am trying to put 50 buttons, 5 per row, in a TileList.
            I have an array with labels to be assigned to each button's label. I didnt want to list each Button inidividually so i thought I would use a repeater. Can itbe done wtihout writing AS code?

            Also any reason why Repeaters don't work inside an Array? After all we are building an array of objects?

            Thanks
            • 3. Re: Why doesn repeater work inTileList?
              Level 7

              "wyattbiker" <webforumsuser@macromedia.com> wrote in message
              news:ga3rf6$g7i$1@forums.macromedia.com...
              >I am trying to put 50 buttons, 5 per row, in a TileList.
              > I have an array with labels to be assigned to each button's label. I didnt
              > want to list each Button inidividually so i thought I would use a
              > repeater. Can
              > itbe done wtihout writing AS code?

              Just set up a dataprovider with the labels of the buttons, then set up
              Button as the itemRenderer. Set your columnCount on the TileList to 5.

              > Also any reason why Repeaters don't work inside an Array? After all we are
              > building an array of objects?

              The dataProvider for pretty much any component needs to be just that...data.
              Not UIComponents.

              HTH;

              Amy


              • 4. Re: Why doesn repeater work inTileList?
                wyattbiker Level 1
                The itemRender idea worked, thank you. I used new ClassFactory(MyButton) class and made a separate custom MyButton component MXML source file.

                P.S. Any idea why the styleName property doesn't work with a custom component? I tried to set the style of a custom Button component and it doesn't show the colors/sizes in Flex.
                • 5. Re: Why doesn repeater work inTileList?
                  Level 7

                  "wyattbiker" <webforumsuser@macromedia.com> wrote in message
                  news:ga5a54$8sr$1@forums.macromedia.com...
                  > The itemRender idea worked, thank you. I used new
                  > ClassFactory(MyButton
                  ) class and made a separate custom MyButton
                  > component
                  > MXML source file.
                  >
                  > P.S. Any idea why the styleName property doesn't work with a custom
                  > component?
                  > I tried to set the style of a custom Button component and it doesn't show
                  > the
                  > colors/sizes in Flex.

                  http://flexdiary.blogspot.com/2008/06/using-css-typeselector-with.html
                  http://flexdiary.blogspot.com/2008/08/tilelist-with-stylefunction.html

                  HTH;

                  Amy


                  • 6. Re: Why doesn repeater work inTileList?
                    wyattbiker Level 1
                    I found out I can set the styleNameon the TileList component. Saves me the headache.