views:

177

answers:

1

I have a Flex repeater that has a complex item template. When a checkbox is clicked, I need to toggle the visibility of a sibling button contained in the same repeater template. Since I can't add binding expressions to event handlers, I can't pass in the repeater item's index.

How can I access sibling components inside a repeater item?

A: 

Since no one has found it in their heart to answer my question, I'll do it myself.

public function onSomeEvent(e:Event):void {
    var checkBox:CheckBox = e.currentTarget as CheckBox;

    targetComponentId[e.target.instanceIndex].visible = !checkBox.selected;
}

When the event is triggered, you can get the instanceIndex from the target property of the event. You just need to reference the right index of the component you are trying to access, as components inside Repeaters are stored as an Array, with the index corresponding to the index of the item in the Repeater list.

steve_c