Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex 使用itemrenderer显示flex progressbar的列表_Apache Flex_Actionscript 3_Flex3_Itemrenderer - Fatal编程技术网

Apache flex 使用itemrenderer显示flex progressbar的列表

Apache flex 使用itemrenderer显示flex progressbar的列表,apache-flex,actionscript-3,flex3,itemrenderer,Apache Flex,Actionscript 3,Flex3,Itemrenderer,我想创建一个进度条列表,并相应地更新该列表。 我将数组中的组数据作为 <mx:Array id="arr"> <mx:Object label="Group One" min="0" max="200" currentValue="60" /> <mx:Object label="Group Two" min="0" max="300" currentValue="50" /> </mx:Array> 数组

我想创建一个进度条列表,并相应地更新该列表。 我将数组中的组数据作为

 <mx:Array id="arr">
        <mx:Object label="Group One" min="0" max="200" currentValue="60" />
        <mx:Object label="Group Two" min="0" max="300" currentValue="50" />
 </mx:Array>

数组对象中的值表示组名、最小值、最大值和当前值 用于组(将在progressbar中使用)

我使用带有“mx.controls.ProgressBar”的列表作为itemRenderer

<mx:List width="100%" dataProvider="{arr}"
        itemRenderer="mx.controls.ProgressBar"/>

现在我需要的是,每当数组“arr”的currentValue字段更改时,我想将progressbar“progress”值更新为currentValue(其中progressbar的最小值和最大值存储在数组“arr”中)

我怎么能这样做呢


谢谢大家

我想你的进度条没有显示任何内容,因为所有这些都是错误的。项目呈现器是一个类,它通过
函数集数据(值:Object):void
从数据提供程序获取单个项目。要在ProgressBar中获取值,您可以对其进行子类化,添加数据函数(getter和setter)并从中设置属性-该类将是项呈现器


其次,不能保证总是实例化ItemRenders。列表根据需要创建它们,并将未使用的存储在池中。这意味着您不能与特定的列表项交谈-池中的任何项都可以发挥其作用(获取其数据)。要更改进度,您需要更新数据提供程序,然后重新设置。

诀窍是将progressbar模式设置为手动,因为您不会自动侦听下载数据的任何进度。您希望设置一个值,以便进度条能够自我更新,因此手动是最好的选择。此外,请查看以下内容:

<s:Application minHeight="600" minWidth="955" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark">
<s:layout>
    <s:HorizontalLayout/>
</s:layout>
<fx:Declarations>
    <s:ArrayCollection id="arr">
        <fx:Object label="Group One" currentValue="20" max="200" min="0"/>
        <fx:Object label="Group Two" currentValue="50" max="300" min="0"/>
    </s:ArrayCollection>
</fx:Declarations>
<fx:Script>
    <![CDATA[
        private function updateArr():void {
            arr.getItemAt(0).currentValue = ns.value;
        }
    ]]>
</fx:Script>
<s:List dataProvider="{arr}"  itemRenderer="ProgressBarWithCurrentValue"/>
<s:NumericStepper id="ns" maximum="200" minimum="0" stepSize="10" value="20" change="updateArr()"/></s:Application>

以下是itemrenderer代码,您将看到手动模式:

<s:ItemRenderer autoDrawBackground="true" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script>
    <![CDATA[
        private function updateCurrentValue():void {
            pb.setProgress(data.currentValue, data.max);
        }
    ]]>
</fx:Script>
<mx:ProgressBar id="pb" maximum="{data.max}" minimum="{data.min}" mode="manual" updateComplete="updateCurrentValue()"/></s:ItemRenderer>

当您简单地将itemrenderer设置为progressbar时,它会自动尝试查找数据源,但在您的情况下,您将为自己提供和更新数据源。因此,您可能需要一个itemrenderer来执行一些操作。

hi all
谢谢你的回答。
在谷歌搜索了更多信息后,我发现了一些类似于我在这里需要的东西

与上面的两个答案非常相似。。作者@kubaba和@alxx..
1.使用ItemRenderer在DataGrid内显示ProgressBar。
2.为DataGrid创建数据提供程序。
3.创建一个操作以启动ProgressBar
4.确保ArrayCollection在项目的每次进度中都得到更新
ProgressBar。

我可以将s更改为mx命名空间,并将集合放入mx脚本块中,但它仍然可以工作。然而,如果它不尊重标签,我很抱歉。