You can create a array of component names such as;
spark.components.Button
spark.components.TextInput
spark.components.CheckBox
spark.components.Label
spark.components.RadioButton
spark.components.DropDownList
mx.controls.DataGrid
spark.components.TextArea
mx.controls.DateField
then pass want you want into this function;
           private function makeElement(className:String, 
COMPONENTID:String):UIComponent {
                var objClass:Class = getDefinitionByName( className ) as Class; 
                
                if( objClass != null ) {                                        
                    var newObject:UIComponent = UIComponent( new objClass() );
                    newObject.id = COMPONENTID;
                    newObject.name = COMPONENTID;
                    return newObject;
                    } 
                else 
                    return null;
            }


then create a switch that looks at the resulting element and add any styles, or 
other properties to the element, or other elements, and add then to your 
container. The dropdown and datagrid will require extra code to provide a 
dataprovider, and you will have to add the default skin by a setStyle, but that 
should get you going in the right direction.

one cavot is that the id is not searchable you will have to search by name in 
the container, if you want to change the element after you add it to the 
container.

I create elements dynamically by quering a database to create the elements 
needed in a flex applicaton, the structure and flow of forms are all in the 
database and I use flex to create the components on the fly...  

Randy 

--- In flexcoders@yahoogroups.com, Angelo Anolin <angelo_ano...@...> wrote:
>
> Hi FlexCoders,
> 
> I came across a Flex PM site and I would like to ask what are the necessary 
> controls / things I need to do to achieve the same application.
> 
> The site's page is:
> 
> http://www.radscientist.com/flexpm/demo/index.html
> 
> I am having problems re-creating those items which expands when the plus sign 
> is 
> clicked as well as adding new items when the Add Milestone button is clicked. 
>  How do I achieve adding controls on the fly on the application?
> 
> I hope you could provide some guidance on this.
> 
> Thanks.
> 
> Angelo
>


Reply via email to