Of course, one needs to use the correct tool for the job. Repeater does not have any performance problems, but misuse of repeater does.
It is incorrect to compare Repeater to the List-based components. Replacing List is not its value. It value is in replacing manual addChild/removeChild code. Consider the original posting, where the need was for a data driven group of radioButtons. Sure, you can easily do a loop and use addChild. But if you want to be able to reference those created components, you will need to code an array to store references. But Repeater does that for you. Now, when you want to change the group of buttons based on new data, you will need to code to remove the old ones, then re-run the add function. But Repeater does that for you. And, if you also have a label, or a button or whatever in the same container as the radio buttons, you will have to code around not deleting those children. Repeater handles that. Because folks have tried to use Repeater to replace List, and been dissatisfied with the result, Repeater has gotten a bad reputation. Like saying plastic is bad because fake wood looks bad. What works best and where? Repeater has a place. Tracy ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Rick Winscot Sent: Saturday, March 22, 2008 10:24 AM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Dynamic creation of radio buttons in a radioButtonGroup Yepper - you hit the nail on the head. The trouble I see so often is that developers open the framework docs and copy/paste a snippit of code... like the output... and begin using it as if it were a silver bullet. When the answer really is to experiment a bit here and there to discover what works best - and where. Rick Winscot 1... 2... 3... hee - it takes three licks to get to the center of a tootsie pop. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Douglas Knudsen Sent: Saturday, March 22, 2008 7:12 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Dynamic creation of radio buttons in a radioButtonGroup This is a ubiquitous 'it depends' moment. Repeater can be very fast and can even recycle children if need be. In this example its simply adding RadioButton so I'd expect it to be fast and no real loss due to no deferred instantiation, eh? Now, if I saw the need to use a Repeater over a custom component based on say VBox I could play with the creationPolicy to get some of that deferred instantiation love. DK On Sat, Mar 22, 2008 at 6:19 AM, Rick Winscot <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: The mx.core.Repeater leans heavily on design-time constructs (e.g. MXML). Without a design-time construct and context to live in... the Repeater as a solution quickly becomes a kludge. Do you find Repeaters to be useful in ActionScript components? Cost... compare using a Repeater and one of the List types. It's all about deferred instantiation... which Repeaters do not take advantage of. Repeating anything more than a few items => use a List. >From the framework docs - "Although Repeater components look like containers in your code, they are not containers and have none of the automatic layout functionality of containers. Their sole purpose is to specify a series of subcomponents to include in your application..." I understand this and can see how my comment could be mistaken. So... with regard to the container comment - please allow me to re-state. As an implementation (container) for repeated objects they aren't very efficient. That is what 'sniffs.' They look great on paper but perform badly. Have you found situations where their benefits outweigh their baggage? If so - it would be great to hear about it (I mean that sincerely) or any alternatives. As for your last comment - the exact opposite is true. The Repeater is the least effective and most expensive way to dynamically populate a List. Rick Winscot From: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> ] On Behalf Of Tracy Spratt Sent: Friday, March 21, 2008 12:09 PM To: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> Subject: RE: [flexcoders] Dynamic creation of radio buttons in a radioButtonGroup Well, Rick, you say, "...repeater is meant to repeat MXML content ..." But it is not limited to mxml content in any way. You say, "...this comes with a cost..." What cost are you talking about? And, "...getting down and dirty with binding and collections ..." What do you mean by that? Repeater does not do anything special with databinding or collections that you would not have to do manually using addChild() to get the same functionality. Finally, "...as a container... they sniff ..." Repeater is not a container. What odor do you think you are detecting? Repeater is a very effective way to dynamically populate a displayList. There is often no reason to rewrite that code yourself. Tracy ________________________________ From: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> ] On Behalf Of Rick Winscot Sent: Thursday, March 20, 2008 11:30 PM To: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> Subject: RE: [flexcoders] Dynamic creation of radio buttons in a radioButtonGroup But remember that the repeater is meant to repeat MXML content at run time... and this comes with a cost - getting down and dirty with binding and collections. Not to mention that as a container... they sniff. Alternatives? var xml:XML = <result> <book title="Book One"/> <book title="Book Two"/> <book title="Book Three"/> <book title="Book Four"/> </result>; // Where you would pass group = "book" and the xml above... private function createRadioGroup( group:String, xml:XML ):void { for each ( var book:XML in xml.elements( group ) ) { var rdo:RadioButton = new RadioButton(); rdo.groupName = group; rdo.label = book.valueOf(); // Where rdoGroup is an HBox rdoGroup.addChild( rdo ); } } Rick Winscot From: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> ] On Behalf Of Tracy Spratt Sent: Thursday, March 20, 2008 1:17 PM To: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> Subject: RE: [flexcoders] Dynamic creation of radio buttons in a radioButtonGroup mx:Repeater. You choose the container depending on the layout you want. Tracy ________________________________ From: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> ] On Behalf Of jeffreyr6915 Sent: Thursday, March 20, 2008 11:24 AM To: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> Subject: [flexcoders] Dynamic creation of radio buttons in a radioButtonGroup Is there a way to dynamically add new radio buttons to a radioButtonGroup say from an xml file? I am looking for a similar functionality to what I would receive if I were to use a dataprovider for a comboBox (except I need to use radio buttons). Code samples are appreciated. Thanks -- Douglas Knudsen http://www.cubicleman.com <http://www.cubicleman.com> this is my signature, like it?