1 Reply Latest reply on May 26, 2011 11:30 AM by Zolotoj

    Dynamically creating elements in dataProvider

    PrettyMuchBryce

      I am trying to figure out how to display a dynamic number of objects with a datagroup and an itemrenderer. The problem is that all the examples I have found only show the data being implemented statically in the MXML tags (see the example below in the ArrayCollection). Is there a way to have an array or vector of objects defined in actionscript that I can dynamically change and have it affect the DataGroup & ItemRenderer?

       

      
      
      
                                         <s:DataGroup itemRenderer="components.itemrenderers.myItemRenderer">
                               <s:layout>
                                    <s:VerticalLayout/>
                               </s:layout>
                               <s:dataProvider>
                                    <s:ArrayCollection>
                                         <local:Person firstName="Alain" lastName="Hufkens"/>
                                         <local:Person firstName="Hugh" lastName="Hefner"/>
                                         <local:Person firstName="Jimi" lastName="Hendrix"/>
                                    </s:ArrayCollection>
                               </s:dataProvider>
                          </s:DataGroup>