This is a syntax error:
Code:
var radioGroup1:RadioButtonGroup = new RadioButtonGroup("Question 1");
So it's just not going to work even without the loop. If I imagine that radioGroup1 is an Object in the global or current scope we can do:
Code:
radioGroup1.RadioButtonGroup = new RadioButtonGroup("Question 1");
If that's the case and the scope is global, we can do:
Code:
window['radioGroup1'].RadioButtonGroup = new RadioButtonGroup("Question 1");
If all that's the case, the loop can be:
Code:
var i = 1, total = 6;
for(i; i < total; ++i){
window['radioGroup' + i].RadioButtonGroup = new RadioButtonGroup('Question ' + i);
}
If we need to create the global radioGroup# Objects, then perhaps:
Code:
var i = 1, total = 6;
for(i; i < total; ++i){
if(!window['radioGroup' + i]){
window['radioGroup' + i] = {};
}
window['radioGroup' + i].RadioButtonGroup = new RadioButtonGroup('Question ' + i);
}
But, that's a lot of if's. If that doesn't solve it for you, we need a link to a demo. Preferably one that works using the:
Code:
var radioGroup1:RadioButtonGroup = new RadioButtonGroup("Question 1");
var radioGroup2:RadioButtonGroup = new RadioButtonGroup("Question 2");
var radioGroup3:RadioButtonGroup = new RadioButtonGroup("Question 3");
var radioGroup4:RadioButtonGroup = new RadioButtonGroup("Question 4");
var radioGroup5:RadioButtonGroup = new RadioButtonGroup("Question 5");
code or something like it. Once I see that, I can make a loop for it. It doesn't have to be all 5 of them, just 2 is enough.
Bookmarks