Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.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
Actionscript 3 从mx:Repeater内部获取mx:CheckBox值_Actionscript 3_Flex3_Mxml - Fatal编程技术网

Actionscript 3 从mx:Repeater内部获取mx:CheckBox值

Actionscript 3 从mx:Repeater内部获取mx:CheckBox值,actionscript-3,flex3,mxml,Actionscript 3,Flex3,Mxml,我有一个对象数组,用作中继器的数据源 <mx:Repeater id="categoryRepeater" dataProvider="{this.allCategories}"> <mx:HBox> <mx:Spacer width="20"/> <mx:CheckBox id="categoryCheckBox" label="{categoryRepeater.currentItem.question}"/> </mx:HBox>

我有一个对象数组,用作中继器的数据源

<mx:Repeater id="categoryRepeater" dataProvider="{this.allCategories}">
<mx:HBox>
<mx:Spacer width="20"/>
<mx:CheckBox id="categoryCheckBox" label="{categoryRepeater.currentItem.question}"/>
</mx:HBox>
</mx:Repeater>


我想知道列表中的哪些复选框已被选中,但我不确定如何做。我知道我可以在单击某个函数时添加它,但我不知道如何判断哪个复选框调用了该函数。

使用该属性。

我意识到这是一篇非常古老的文章,但我遇到了同样的问题,currentIndex对我来说不是一个足够的答案。我发现更好的方法是在单击时创建一个函数:

<mx:Repeater id="rp" dataProvider="{dp}">  
<s:CheckBox height="100%" width="100%" label="{String(rp.currentItem)}"  
click="showAlert(event);"/>
</mx:Repeater>

通过这种方式,您可以将事件作为ActionScript代码中的复选框来处理,并查找值,例如是否已选择该事件等。

您能为我指出示例的方向吗?以下是我正在尝试的:但是,似乎从未调用过该函数,也就是说categoryRepeater.currentIndex我最初发布的Flex 3文档的链接底部有一个示例。只需将currentTarget.getRepeaterItem()替换为currentTarget.currentIndex,然后重试。
private function showAlert(evt:MouseEvent):void {
  var curBox:CheckBox = evt.currentTarget as CheckBox;
  var str:String = curBox.content.toString();
  if(curBox.selected)
    Alert.show(str + " clicked");
}