To add to what Tracy was saying.. Let's say you have a component in the comps directory called MyComp. It could be in MXML or in Actionscript, it doesn't matter.
First you would need to import that component definition by saying import comps.MyComp; Then, at anytime, for instance in response to a button click, you can say: var someVar:MyComp = new MyComp(); someVar.property1 = 3; someVar.property2 = 7; this.addChild( someVar ); or myViewStack.addChild( someVar ); You could make a series of functions which create these components and set them, calling the appropriate function when needed. Or you could dig a little further and learn about factories... is this basically what you were trying to do or are we missing your point? Mike --- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> wrote: > > You understand that if you use navigation containers, like viewStack and > TabNavigator, that much of this is done for you automatically? > > > > Also, separate mxml files is a fine way to make re-useable components. > Their size is not significant. Make them generic so that you can set > properties and event listeners. > > > > I don't know if the <mx:Component> tag can be used anywhere other than > in an item renderer(state?), but you might check. > > > > And you can instantiate controls at will using container.addChild(). > > > > There are also RSLs and modules. > > > > Mxml is just another way to write AS classes, use it if you like it. > > > > There are lots of options. > > > > Tracy > > > > ________________________________ > > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of gary_mangum > Sent: Tuesday, May 29, 2007 6:30 PM > To: [email protected] > Subject: [flexcoders] Defining a dynamic UI > > > > Is it possible to "pre-define" a set of MXML components but not create > them or add them to a Container in the application until a later time. > In other words, I want to define some components, complete with > properties, events, etc. that will not be part of my UI until I > dynamically add them as the application runs. I will decide whether > or not to add them based on runtime criteria. > > I know that I can use states to add and remove components. If I use > states, is there a way to define a component only once in MXML and > then add it in 3-4 different states? I do not wish to define my > component over and over inside of AddChild tags, and my components are > not really specialized enough to warrant their own MXML files since > there are many of them and the only real differences are their > properties, events, etc. > > I've also thought that I could manually define my components in AS and > keep them in memory until needed, but would rather define them in MXML > if possible. I would also like to create the components > "just-in'time" instead of creating them up front when they may never > be needed. > > Anyway, thanks for any thoughts on this topic! >

