Interesting topic !
I would like to go further on the dynamic class manipulations:
Does anybody see a way to list all classes from a package that implement a
given Interface ?
Well, the part "that implement a given Interface" is easy to do using
isPrototypeOf(), but the "list all classes from a package" part ?

2009/7/14 ag_rcuren <[email protected]>

>
>
> To return a class is pretty simple. If you look at the source of the
> Modules they have create method. For my example they are returning instances
> but there is no reason you can not return a Class from these, infact I have
> done it before so I know it works.
>
> import mystuff.junk.SomeClass;
> import mystuff.junk.AnotherClass;
>
> public function create(type:String):*
> {
> switch (type)
> {
> case "SomeClass":
> return SomeClass
> case "AnotherClass":
> return AnotherClass
> break;
> default:
> break;
> }
> return null;
> }
>
> This will give you back a Class which you can then use as expected.
>
> Looking at it now I should have used a different name other than
> createdInstance for the getter in DynamicFactory because it really does not
> have to be an instance of something it can be any type.
>
>
> --- In [email protected] <flexcoders%40yahoogroups.com>,
> "postwick" <p...@...> wrote:
> >
> > Thanks for everyone's help. I think this points me in the right
> direction.
> >
> > Of course, if there's a way to successfully use data messaging without
> instantiating classes...that would eliminate my need to do this. But I don't
> think there is...
> >
> > --- In [email protected] <flexcoders%40yahoogroups.com>,
> "ag_rcuren" <robert.vancuren.jr@> wrote:
> > >
> > > Yes you could create the class and build it into an RSL. Once the RSL
> is loaded you can just reference it by name. When you add or make changes
> you just need to rebuild the RSL or push a new RSL out and have a way for
> your app to know whats available.
> > >
> > > I found it easier to use Modules, because they are easier to build. I
> have examples of both RSL and Modules on that blog both have source enabled
> so you can take a look.
> > >
> > > I have an app that lets users pick and choose "widgets" they want and I
> load only the components they want into the app via a config file. When ever
> I want to add new components I just publish a new module and update my
> database so my apps knows about it.
> > >
> > > --- In [email protected] <flexcoders%40yahoogroups.com>,
> "postwick" <paul@> wrote:
> > > >
> > > > From your blog post...
> > > >
> > > > var myClass:Class =
> getDefinitionByName("com.myDomain.myPackage.SomeClass");
> > > >
> > > >
> > > > Does this mean I don't have to create the class as a .as file and
> compile it into the SWF, I can just reference it this way? Then I could add
> a new class to myPackage and tell my app (via db, XML, etc) that there is a
> new class there to load?
> > > >
> > > > The point to all of this is a dynamic application where an end user
> can add their own tables, and I need classes for those objects so that I can
> pass them back and forth with data messaging.
> > > >
> > > >
> > > > --- In [email protected] <flexcoders%40yahoogroups.com>,
> Alan Shaw <nodename@> wrote:
> > > > >
> > > > > There are a number of important techniques for manipulating classes
> (as detailed
> > > > > in my post http://nodename.com/blog/2008/06/15/upon-reflection/ ),
> but
> > > > > unfortunately
> > > > > creating a class at runtime is not possible in AS3.
> > > > >
> > > > > On Mon, Jul 13, 2009 at 8:23 PM, postwick<paul@> wrote:
> > > > > >
> > > > > >
> > > > > > I want to store descriptions of classes in an external file (such
> as XML) or
> > > > > > database, and use them in my Flex application such that I can
> add, remove,
> > > > > > or change the classes in the external file with recompling the
> Flex
> > > > > > application.
> > > > > >
> > > > > > Is there any way to do this? In a nutshell, is there a way to
> create a class
> > > > > > through an Actionscript function, with a for loop where the
> information that
> > > > > > is looped over contains the definitions of the classes loaded
> from an
> > > > > > external source?
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
>  
>

Reply via email to