1 Reply Latest reply on Aug 7, 2006 11:01 AM by peterent

    mx:Repeater and strings from array objects

    ChrisCharlton Level 1
      I'm using Repeater and trying to use its' index to access an array's data to render folders as panels. I get warnings that I should be using ArrayCollection (for that folderHeading String I'm trying to make).

      <mx:Repeater id="rpFolders" dataProvider="{folders}">

      [Bindable] public var folderHeading:String = "Folder: "+folders[rpFolders.currentIndex].folderName +" (size: "+ folders[rpFolders.currentIndex].folderSize +")";

      <mx:Panel width="300" height="150" layout="absolute" title="{folderHeading}">
      <mx:Tree width="100%" height="80" showRoot="true" dragMoveEnabled="true" dataProvider="{files}" labelField="@label" top="50"></mx:Tree>
        • 1. Re: mx:Repeater and strings from array objects
          peterent Level 2
          I see that you have Script block within the Repeater block. That's OK, but it is not doing what you think. The placement of the Script block does not matter as long as it is good XML. The Flex compiler just yanks it out of there and puts all of the script code together.

          Try this instead:

          <mx:Panel title="{folders[rpFolders.currentIndex].folderName+'(size: '+folders[rpFolders.currentIndex].folderSize+')'" />

          (note the use of single quotes within the { } code). If you still get the data binding warning, then try this:

          <mx:Panel title="{folderTitle(rpFolders.currentIndex)}" >

          Then in that Script block, write the function:

          private function folderTitle( index:Number ) : String {
          return rpFolders[index].folderName+'(size: '+folders[index].folderSize+')';