You can make modules on the fly with just the classes you want and pull them down. Modules supporting a shared interface may be best for you.
RSLs are best for sharing code between applications. See my modules preso on my blog. ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of phall121 Sent: Thursday, June 07, 2007 10:21 AM To: [email protected] Subject: [flexcoders] Re: Selecting which Child Components to add at runtime--Dynamic UI & RSL Yes, Alex, I finally got getDefinitionByName to help instantiate a custom component as a class at runtime from a string (in a query- result array). Your warning about needing to make sure the classes are linked into the SWF was right on-the-mark! I thought that by importing the components package, this made sure all the component classes were included in the SWF. Apparently not. Based on a suggestion from Gordon, I am declaring the class with: private static var clTestComp1:TestComp1 ...this works. The problem is, like you say, you have to know the total set of classes you want to use. We are building a Dynamic UI, so we have an expanding list of components that the user may be qualified to add to the application at runtime. We don't want to have to declare all of the components with hard-coded static vars. And, we can't know and declare today the full list of classes that may be available in the future. Can someone advise: Is RSL (runtime shared libraries) the best practice for bringing in from the server only the components needed at runtime? (note: In our application, a table at startup shows which components the user is qualified for, the user may only click to a sub-set of components they are qualified for. We want to add those selected custom components as views to a ViewStack.) Will RSL let us pull in (instantiate) selected component classes from the strings in the query result array? Will we pull down the whole RSL or just the classes that are needed? Thanks --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "Alex Harui" <[EMAIL PROTECTED]> wrote: > > getDefinitionByName and getDefinition. You will still need to make sure > the classes are linked into the SWF, so you have to know the total set > of classes you want to use. > > > > ________________________________ > > From: [email protected] <mailto:flexcoders%40yahoogroups.com> [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com> ] On > Behalf Of phall121 > Sent: Wednesday, June 06, 2007 8:50 AM > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > Subject: [flexcoders] Re: Selecting which Child Components to add at > runtime > > > > Alex's solution to the original challenge of selecting which Child > components to add at runtime, worked very well with the adjustments > mentioned. > > However, the function to instantiate & add the Child component > requires a class parameter dynamically specified at runtime. > > The mx.ComboBox approach described works...by surrounding the > package/name of the component with curly braces, Flex manages to > pass the actual component(reference) to the function. > --So, the string of "{components.Comp1}" is passed as an actual > class reference. > > But, to make the Dynamic UI "table-driven"...to specify which Child > components to add using an array...I must find a way in ActionScript > to convert the strings into the actual component reference. (Can't > use the curly brace approach, since curly braces work in Flex, not > Actionscript.) > > How, in AS, can you convert a string ("components.Comp1") into the > actual reference to the component? This is very basic. I'm > embarrassed to not know the answer. I've combed the docs and the > FlexCoder archives. > > I tried explicit coercion or casting: > > private function fAddApps():void > { > var clComp:Class = Class(acCompList.getItemAt(2).compname); > fAddCustomView(clComp); > } > > private function fAddCustomView(compClass:Class):void > > This didn't work > > Does anyone have a suggestion? >

