0
votes

In flex 3, I have created the child components in the canvas using the repeater component. I want to made changes in only one of the child component created by repeater. Is there any method or way to access the particular child component and made required property changes ?

<mx:Repeater id="myrep" dataProvider="{myAC}"> 
    <mx:Label id="Label1" text="This is button "/>
</mx:Repeater> 

In above code suppose I have create 10 label and I want to apply some changes in 5th Label only ? Is it possible.

Thanks

1

1 Answers

1
votes

Yes, it's possible.

You could access repeater's generated components like this:

component_id[index]

So in your case,for changing 5th element's label, your code would be Label1[4].text='blah blah'. However changing repeater's generated components in this manner, is a bad practice. Instead use bindings.

For example:

//...
[Bindable]
var myAC:ArrayCollection = new ArrayCollection(["label1","label2","label3","label4","label5","label6"]) ;
//...
<mx:Repeater id="myrep" dataProvider="{myAC}"> 
   <mx:Label id="Label1" text="{myrep.currentItem}"/>
</mx:Repeater> 
//Changing label of 5th element
myAC[4] = 'blah blah';