5 Replies Latest reply on Oct 2, 2008 11:10 AM by Newsgroup_User

    Repeater with custom component

    Cr99 Level 1
      I have a repeater that needs to display a series of Images with Labels. I need to be able to drag these labels around and change the order.

      The labels and icons represent a custom Actionscript class I have called ChartObject. Since the image and label need to be dragged together, I put them together in a custom class based of VBox (called ChartIcon). How can I get the ChartIcons to map to the ArrayCollection of ChartObjects which make up the Repeater?


        • 1. Re: Repeater with custom component
          Level 7

          "Cr99" <webforumsuser@macromedia.com> wrote in message
          news:gbtknn$b42$1@forums.macromedia.com...
          >I have a repeater that needs to display a series of Images with Labels. I
          >need
          > to be able to drag these labels around and change the order.
          >
          > The labels and icons represent a custom Actionscript class I have called
          > ChartObject. Since the image and label need to be dragged together, I put
          > them
          > together in a custom class based of VBox (called ChartIcon). How can I
          > get the
          > ChartIcons to map to the ArrayCollection of ChartObjects which make up the
          > Repeater?
          >
          >
          >
          >
          > <mx:Repeater id="rp" dataProvider="{chartArrayCollection}" >
          > <components:ChartIcon id="chartIcon"/>
          > </mx:Repeater>
          >
          > // ChartIcon custom opponent
          >
          > <?xml version="1.0" encoding="utf-8"?>
          > <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml" >
          >
          > <mx:Script>
          > <![CDATA[
          > import factory.data.ChartObject;
          >
          > var chart:ChartObject; // Actionscript object
          > ]]>
          > </mx:Script>
          >
          > <mx:Image source="{chart.getIconURL()}" />
          > <mx:Label id="chartName" text="{chart.getName()}" />
          >
          > </mx:VBox>


          Look at currentItem:
          http://livedocs.adobe.com/flex/3/html/repeater_3.html

          Use it to set a public property on your class.


          HTH;

          Amy


          • 2. Re: Repeater with custom component
            ntsiii Level 3
            Yep:
            <components:ChartIcon id="chartIcon" acData="{rp.currentItem}"/>

            And implement "acData" as a public property in ChartIcon.

            More snippets below.
            Tracy

            • 3. Re: Repeater with custom component
              Level 7

              "ntsiii" <tspratt@lariatinc.com> wrote in message
              news:gbu1ns$seo$1@forums.macromedia.com...
              > Yep:
              > <components:ChartIcon id="chartIcon" acData="{rp.currentItem}"/>
              >
              > And implement "acData" as a public property in ChartIcon.
              >
              > More snippets below.

              That seems to be formatted like a cookbook post. Is it up on the web? I
              could link to it in the faq.


              • 4. Re: Repeater with custom component
                ntsiii Level 3
                Sorry I don't have that posted anywhere public. I will look into doing that.
                Tracy
                • 5. Re: Repeater with custom component
                  Level 7

                  "ntsiii" <tspratt@lariatinc.com> wrote in message
                  news:gc318h$l04$1@forums.macromedia.com...
                  > Sorry I don't have that posted anywhere public. I will look into doing
                  > that.

                  Cool :-)