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

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

问题描述

我想在Accordian中设置进度条的值,但是遇到"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属性中的项目那是用来生产物体的.当Repeater组件完成时重复一遍,您可以使用使用getRepeaterItem()方法确定事件处理程序应该基于什么在currentItem属性上.为此,你通过了event.currentTarget.getRepeaterItem()事件处理程序的方法.这getRepeaterItem()方法需要一个指定哪个索引的可选索引您想要的中继器组件嵌套的Repeater组件是展示;0索引是最外面的中继器组件.如果你不指定索引参数,最里面的Repeater组件是暗示.

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.

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

You can read more about this in the Repeater docs.

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

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