设置进度条的进度值时出现“setProgress 不是函数"错误 [英] 'setProgress not a function' error while setting progress value of a progress bar

查看:45
本文介绍了设置进度条的进度值时出现“setProgress 不是函数"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在手风琴中设置进度条的值,但遇到setProgress 不是函数"错误.知道以下代码有什么问题.

I want to set value of a progress bar in an accordian but I am encountering 'setProgress is not a function' error. Any idea what's wrong with following code.

观察:如果我将进度条从 Accordian 中移出,那么错误就会消失并且进度条显示正常.

Observation: If I move the progress bar out of the Accordian then the error goes away and the progress bar appears fine.

我想最终将进度条设置为 {repMonitor.currentItem.threatLevel} 但现在我只是用假设的威胁值进行测试,即 60

I want to set the progress bar eventually to {repMonitor.currentItem.threatLevel} but for now I am just testing with hypothetical threat value i.e 60

<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" creationComplete="bar.setProgress(60,100);" />
      </mx:Canvas>
   </mx:Repeater>
</mx:Accordion>

推荐答案

这源于您的 ProgressBar 位于中继器中.您不能通过 id 引用重复项,因为您将拥有可变数量的 ID 为bar"的 ProgressBar.

This stems from the fact that your ProgressBar is in a repeater. You cannot reference the repeated items by id because you would have a variable number of ProgressBars with id "bar".

在Repeater 对象内部使用事件侦听器时还有一些特殊注意事项:

There are also special considerations when using event listeners inside of Repeater objects:

Repeater 组件中的事件处理程序

当中继器组件忙时重复,每个重复的对象它创造可以在那一刻绑定到Repeater 组件的 currentItem属性,随着中继器组件重复.你不能给每个实例它自己的事件处理程序通过编写类似的东西click="doSomething({r.currentItem})"因为绑定表达式不是允许在事件处理程序中,以及所有重复组件的实例必须共享相同的事件处理程序.

When a Repeater component is busy repeating, each repeated object that it creates can bind at that moment to the Repeater component's currentItem property, which is changing as the Repeater component repeats. You cannot give each instance its own event handler by writing something like click="doSomething({r.currentItem})" because binding expressions are not allowed in event handlers, and all instances of the repeated component must share the same event handler.

重复组件和重复中继器组件具有返回的 getRepeaterItem() 方法dataProvider 属性中的项目用于生成对象.当中继器组件完成时重复,您可以使用getRepeaterItem() 方法来确定事件处理程序应该基于什么做在 currentItem 属性上.为此,你通过event.currentTarget.getRepeaterItem()事件处理程序的方法.这getRepeaterItem() 方法需要一个可选索引,指定哪个您需要的中继器组件嵌套的中继器组件是展示;0 索引是最外面的中继器组件.如果你不指定索引参数,最里面的中继器组件是暗示.

Repeated components and repeated Repeater components have a getRepeaterItem() method that returns the item in the dataProvider property that was used to produce the object. When the Repeater component finishes repeating, you can use the getRepeaterItem() method to determine what the event handler should do based on the currentItem property. To do so, you pass the event.currentTarget.getRepeaterItem() method to the event handler. The getRepeaterItem() method takes an optional index that specifies which Repeater components you want when nested Repeater components are present; the 0 index is the outermost Repeater component. If you do not specify the index argument, the innermost Repeater component is implied.

您可以在中继器文档中阅读有关此的更多信息.

You can read more about this in the Repeater docs.

这篇关于设置进度条的进度值时出现“setProgress 不是函数"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆