Results 1 to 3 of 3

Thread: I got crazy becouse this

  1. #1
    Join Date
    Aug 2008
    Location
    karanganyar, solo, indonesia
    Posts
    161
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Unhappy I got crazy becouse this

    How to generate radiobuttonGroup on looping like below?
    Code:
    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

    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");
    can somebody help me? thanks
    ///////////////////////////////////////////////////
    ///// http://www.mediatutorial.web.id
    ///////////////////////////////////////////////////

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    smansakra (12-05-2011)

  4. #3
    Join Date
    Aug 2008
    Location
    karanganyar, solo, indonesia
    Posts
    161
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Thumbs up Solved thanks !

    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.
    somebody has replied my quenstion here-> http://www.actionscript.org/forums/s....php3?t=268374

    THANKS SO MUCH
    ///////////////////////////////////////////////////
    ///// http://www.mediatutorial.web.id
    ///////////////////////////////////////////////////

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •