I advise using mx:Repeater for this.
It is essentially the same as using addChild, but automates a lot of things, like creating an array of references to the created children, and handling removing the children, even if there are other manually added children in the container. If you code it manually, you will have to code these things yourself. Still, use a custom component, and repeat that. Pass in a reference to the entire currentItem. This way you can code normally within the component, without the getRepeaterItem stuff. Provide a public property containing the dataProvider item, an you can access that item in any event handler your custom component may dispatch. Side note, rarely, if ever, does it matter whether you implement a component in AS or mxml. One exception is itemRenderers, when you need to avoid containers for performance sake. Repeater renders as many children as is specified by the "count" property (or all items in the dataProvider if count is not specified). 10-20 complex components might be a bit slow. Fewer are less of a problem. You would have the same issue with manually instantiating the components. Also note that Repeater does not need to make a list. Use a container with absolute layout, and you can put the instances wherever you want. Tracy ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Schmalle Sent: Wednesday, June 25, 2008 2:19 PM To: [email protected] Subject: Re: [flexcoders] Dynamically creating instances of custom components Hi, If I am understanding you correctly, an MXML component is a class in itself. So if you have a mxml component named MyCustomComponent.mxml, you would do this when create the dynamic UI; var child:MyCustomComponent = new MyCustomComponent(); .. initialize container.addChild(child); You can expand greatly on this but, you might be missing that the mxml file is converted into a actionscript class when it gets compiled. Don't forget to import it. Mike -- Teoti Graphix, LLC http://www.teotigraphix.com <http://www.teotigraphix.com> Teoti Graphix Blog http://www.blog.teotigraphix.com <http://www.blog.teotigraphix.com> You can find more by solving the problem then by 'asking the question'.

