?
Solved

Dynamic creation of radio buttons in a radio group, using a custom object?

Posted on 2009-04-09
2
Medium Priority
?
830 Views
Last Modified: 2012-05-06
All,

I'm looking for information on how to create a radio button group, based on the contents of an list of objects.
These objects, of type "Answer" have 2 string properties of "answerLetter" and "answerValue".

What I want to do is iterate over this collection of Answer objects, and create a radio button group, with the label being the Answer Value and the data being the Answer Letter.

How would I do this?  It appears to be adding the contents of my array collection as new radio buttons, but they are all on top of each other.  How do I space them out?  The text values appear to be populating correctly, but there appears to be n number of buttons on top of each other...
Simple answer class...
 
public class Answer
{
	private var _answerText:String;
	private var _answerLetter:String;
		
	public function Answer(...args)
    	{
  		this._answerLetter = args[0];
    		this._answerText = args[1];     		
    	}
		
        public function get answerText():String{
            return _answerText;
        }
        
        public function set answerText(answerText:String):void{
            _answerText = answerText;
        }
        
        public function get answerLetter():String{
            return _answerLetter;
        }
        
        public function set answerLetter(answerLetter:String):void{
            _answerLetter = answerLetter;
        }     
}
 
The panel has this on it.
 
<mx:RadioButtonGroup id="answerGroup" />
        <mx:Repeater id="rep" dataProvider="{cbCol}">
                <mx:RadioButton group="{answerGroup}" id="radios" label="{rep.currentItem.answerText}" data="{rep.currentItem.answerLetter}" />
        </mx:Repeater>
 
cbCol is populate when this method is called.
public function CreateRadioButtons(answersForThisQuestion:ArrayCollection){
				
	cbCol = new ArrayCollection();
	for(var i:int = 0; i<answersForThisQuestion.length; i++){		  cbCol.addItem(answersForThisQuestion.getItemAt(i) as Answer);
	}
			
}

Open in new window

0
Comment
Question by:csciguy81
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
Fuzzy_Logic_ earned 200 total points
ID: 24110470
Put the RadioButtonGroup in a Tile component.
<mx:Tile direction="horizontal">
 
<mx:RadioButtonGroup id="answerGroup" />
        <mx:Repeater id="rep" dataProvider="{answersForThisQuestion}">
                <mx:RadioButton group="{answerGroup}" id="radios" label="{rep.currentItem.answerText}" data="{rep.currentItem.answerLetter}" />
        </mx:Repeater>
 
    
</mx:Tile> 

Open in new window

0
 

Author Closing Comment

by:csciguy81
ID: 31568662
Worked great!  Thanks!
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question