如何使用getRepeaterItem来设置进度条的进度?

时间:2011-03-02 05:04:23

标签: flex flex3 flex4

我在转发器中有一个进度条,因此我需要使用getRepeaterItem来设置this问题中建议的进度。

我怎样才能这样做,以便可以从repMonitor.currentItem.threatLevel获取进度值?

<mx:Accordion id="monAccordian" includeIn="Monitoring" x="10" y="10" width="554" height="242" change="monAccordianChange()" >       
   <mx:Repeater id="repMonitor" dataProvider="{monitoringArray}">
      <mx:Canvas width="100%" height="100%" label="{repMonitor.currentItem.firstName+' '+ repMonitor.currentItem.lastName}" >
        <mx:Image x="10" y="10" source="{repMonitor.currentItem.imageName}" width="175" height="118"/>
        <s:Label x="200" y="14" text="Threat Level:"/>
          <mx:ProgressBar x="200" y="30" mode="manual" label="" id="bar" width="200" />
      </mx:Canvas>
   </mx:Repeater>
</mx:Accordion>

1 个答案:

答案 0 :(得分:0)

每次威胁等级更改时都需要调用此函数以更新Repeater项:

        private function updateProgresses() : void
        {
            if (!bar) return;
            for (var i : int = 0; i < bar.length; i++)
            {
                var p : ProgressBar = bar[i] as ProgressBar;
                if (p)
                {
                    p.setProgress(monitoringArray[i].threatLevel, 100);
                }
            }
        }

private function updateProgresses() : void { if (!bar) return; for (var i : int = 0; i < bar.length; i++) { var p : ProgressBar = bar[i] as ProgressBar; if (p) { p.setProgress(monitoringArray[i].threatLevel, 100); } } }