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

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

问题描述

我想在一个手风琴上设置一个进度条的值,但是我遇到了setProgress不是一个函数的错误。任何想法下面的代码有什么问题。观察:
如果我将进度条移出手风琴,那么错误消失,进度条显示正常。

$ b

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

 < mx:Accordion id =monAccordianincludeIn =Monitoringx =10y =10width =554height =242change =monAccordianChange ()> 
< mx:Repeater id =repMonitordataProvider ={monitoringArray}>
< mx:Image x =10y =10source ={repMonitor.currentItem.imageName}width =175height =118/>
< / mx:Canvas>
< / mx:中继器>
< / mx:Accordion>


解决方案

这是因为ProgressBar在中继器。你不能通过id引用重复的项目,因为你将有一个可变数量的id为bar的ProgressBars。



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

lockquote

Repeater组件中的事件处理程序

当Repeater组件忙于
重复时,每个重复的对象
创建可以绑定到
Repeater组件的currentItem
属性,这个属性随着
Repeater组件的重复而改变。你不能
给每个实例赋予自己的事件
处理器通过编写类似于
的函数click =doSomething({r.currentItem})
因为绑定表达式不是
允许在事件处理程序中,而重复组件
的所有
实例必须共享相同的事件处理程序。



重复的组件和重复的
Repeater组件有一个
的getRepeaterItem()方法,该方法返回
dataProvider属性
中用于生成对象的项目。
当Repeater组件完成
重复时,可以使用
getRepeaterItem()方法确定
事件处理程序应该在currentItem属性上基于
执行的操作。为此,

event.currentTarget.getRepeaterItem()
方法传递给事件处理程序。
getRepeaterItem()方法带有一个
可选索引,它指定当
嵌套的Repeater组件是
present时需要的
Repeater组件; 0索引是最外面的
Repeater组件。如果你不
指定索引参数,则
最内层的Repeater组件是


您可以在Repeater文档中阅读有关此的更多信息< a>。


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.

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

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>

解决方案

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".

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

Event handlers in Repeater components

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.

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 not a function”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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