View Full Version : I got crazy becouse this
smansakra
12-04-2011, 09:45 AM
How to generate radiobuttonGroup on looping like below?
var i:int;
var total:int = 6;
for(i=1; i<total; i++){
var radioGroup+i:RadioButtonGroup = new RadioButtonGroup("Question "+i);
}
but i doesn't work, :'(
i want to produce 5 radiogroups from looping like below
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");
can somebody help me? thanks
jscheuer1
12-04-2011, 06:28 PM
This is a syntax error:
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:
radioGroup1.RadioButtonGroup = new RadioButtonGroup("Question 1");
If that's the case and the scope is global, we can do:
window['radioGroup1'].RadioButtonGroup = new RadioButtonGroup("Question 1");
If all that's the case, the loop can be:
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:
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:
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.
smansakra
12-05-2011, 07:42 AM
Hello jscheuer1,
thanks for reply,,,
sorry for my mitakes, it was actionscript, i should put it on FLASH category, sorry i placed it on JAVASCRIPT category.
:rolleyes: somebody has replied my quenstion here-> http://www.actionscript.org/forums/showthread.php3?t=268374
THANKS SO MUCH
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.