2 Replies Latest reply on Jul 28, 2009 11:04 AM by Zolotoj

    Repeater

    Zolotoj Level 3

      My repeater:

      <mx:Repeater id="rp" recycleChildren="false" startingIndex="0">
           <ns1:sewerPanel data="{rp.currentItem}">
           </ns1:sewerPanel>
      </mx:Repeater>
      

       

      data:

      var node:XML;
      for each (node in resultXML.scanningline)
      {
      dp.push(node);
      }     
      rp.dataProvider = dp;
      rp.validateNow();
      trace(rp.getChildAt(0));
      

      It fails at trace(rp.getChildAt(0));

      The supplied Index is out of bounds

       

      How do I access repeater's children then?

        • 1. Re: Repeater
          Gregory Lafrance Level 6

          Give the repeater child an id and then use it as an array:

           

          <mx:Repeater id="rp" recycleChildren="false" startingIndex="0">
               <ns1:sewerPanel id="mySewer" data="{rp.currentItem}">
               </ns1:sewerPanel>
          </mx:Repeater>

           

          Somewhere else:

           

          for(var a:uint=0; a<mySewer.length(); a++){

            trace(mySewer[a].toString());

          }

           

          If this post answered your question or helped, please mark it as such.

           

           

          <?xml version="1.0"?> 
          <!-- repeater\RefRepeatedComponents.mxml -->
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
              <mx:Script>
                  <![CDATA[
                      public function labelTrace():void {
                          for (var i:int = 0; i < nameLabel.length; i++)
                              trace(nameLabel[i].text);
                      }
                  ]]>
              </mx:Script>
              <mx:Model id="catalog" source="../assets/repeater/catalog.xml"/>
              <mx:ArrayCollection id="myAC" source="{catalog.product}"/>
              <mx:Label id="title" text="Products:"/>
              
              <mx:Repeater id="r" dataProvider="{myAC}" startingIndex="1">
                  <mx:Label id="nameLabel"
                      text="{r.currentItem.name}: ${r.currentItem.price}"
                      width="200"/>
              </mx:Repeater>
              <mx:Button label="Trace" click="labelTrace();"/>
          </mx:Application>
          
          • 2. Re: Repeater
            Zolotoj Level 3

            Works, thanks