-3

In our code we are dynamically adding checkbox into a vgroup. code follows something like this

FLEX 3:::

var tempVBox:VBox = new VBox;
var tempCheckbox:Checkbox = new Checkbox;
tempCheckbox.id="someid";
tempCheckbox.label="somelabel";
tempCheckbox.event="someevent";
tempVgroup.addChild(tempCheckbox);

and in same actionscript we have another function to getcheckbox element to perform some operation like select all. Code follows like

var tempVBox:VBox = new VBox;
for(i=0;i<tempVBox.numChildren;i++){
tempVBox.getChildAt(i)
}

Alert.show(tempVBox.getChildAt(i)) will be some thing like VBox660.Checkbox998 But in flex4 the code changed like this

FLEX4 ::::

var tempVgroup:VGroup = new Vgroup;
var tempCheckbox:Checkbox = new Checkbox;
tempCheckbox.id="someid";
tempCheckbox.label="somelabel";
tempCheckbox.event="someevent";
tempVgroup.addElement(tempCheckbox);

and in same actionscript we have another function to getcheckbox element to perform some operation like select all. Code follows like

var tempVgroup:VGroup = new Vgroup;
for(i=0;i<tempVgroup.numElements;i++){
tempVgroup.getElementAt(i)
}

Alert.show(tempVgroup.getElementAt(i)) will give VGroup889.House-OWner

House-OWner is id set for checkbox...

Can anyone help me in this i need to get element like this VGroup660.Checkbox998

sorry if code makes no logic as i wrote completely in browser

Thanks

2 Answers2

0

Maybe I don't understand, but group.getElementAt(i) returns Checkbox, but not id. So, I can change "selected" property: (group.getElementAt(i) as CheckBox).selected = true;

Daniil Subbotin
  • 6,138
  • 5
  • 20
  • 24
  • Thanks for reply..i didn't understand even at adding checkbox i gave Alert.show(tempCheckbox)before tempvbox.addElement(tempCheckbox) gives me id of the checkbox – tollywood flick Feb 10 '15 at 10:35
0

In Flex 4.. the UID property worked to get the element as a checkbox.I have tried with different components like radiobuttion,checkbox,button and for everything the addElement()or getElement() returns the id of element if id for element is set..if Id was not set it is returning as checkbox.In the view you can see checkbox in both the cases but in the script the element is returning id if we set id to element.So I used UID(unique Id) property instead of Id and it worked.

var tempVgroup:VGroup = new Vgroup;
var tempCheckbox:Checkbox = new Checkbox;
tempCheckbox.uId="someid";
tempCheckbox.label="somelabel";
tempCheckbox.event="someevent";
tempVgroup.addElement(tempCheckbox);

This scenario of getting checkbox as element is useful when we try to perform any sort opertion from array of different elements.I can use if(String(VGroup.getElementAt(i).toString()).indexOf("CheckBox",0)>1) statement to get only checkboxes.

Can any one explain about this difference between flex 3 and flex 4