I'm building a quiz canvas, where the user enters a number of
responses into textInput fields, and then hits a Submit button to
remove their textInput fields, and display the correct feedback for
I'm having trouble with being able to refer to repeated
objects (created by a repeater) when changing states using MXML. Do
I need to do it in ActionScript? Or is there some way of looping in
MXML - do I need another repeater in the part where I change states
to loop through and delete my textInput objects?
Also, when I change states and use removeChild(), does that
actually delete the object, or does it merely hide it?
First, if you give a repeated component an id, you can
reference a specific repeated instance of that component using the
item index in the data Provider:
var vbCurrent:VBox = vBox[n]; //where "n" is the index of the
Using this you can loop over all the repeated items.
Additionally, when using a repeater, it often simplifies
coding if you create a custom component, with all the repeated
stuff in it, and repeat that. Pass in a reference to the entire
dataProvider item. This lets you code normally within the
component, to easily dispatch events, and to access the
dataProvider item in the event handlers. Otherwise, programming
interactions between the repeated controls is very messy, requiring
getRepeaterItem(), among other extra work.