That's one of the reasons all of our mxml classes have no constructor
arguments.

 

The code flow is then:

 

result = new clazz();

for (var p:String in args)

{

   results[p] = args[p];

}

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Christophe Herreman
Sent: Friday, April 06, 2007 11:55 AM
To: [email protected]
Subject: Re: [flexcoders] Re: Dynamic constructor invocation?

 

Hi again,

the solution I have so far is to make separate calls for each number of
arguments that needs to be passed to the constructor. It works, but of
course it is no elegant and generic solution.

case 1:
result = new clazz(args[0]);
break;
case 2:
result = new clazz(args[0], args[1]);
break;

etc.

regards,
Christophe

herrodius schreef:
>
> Hi Paul,
>
> I'm currently also creating a lightweight IoC container. You can get a
> ref to the Class by calling getDefinitionByName(). getClassByName() is
> indeed not there.
>
> About the ObjectFactory, do you mean creating wrappers around the
> constructor call for every number of arguments? You can always send me
> code offlist ([EMAIL PROTECTED] <mailto:info%40herrodius.com>
<mailto:info%40herrodius.com>). If 
> you are interested in my
> progress I can send you some stuff to.
>
> regards,
> Christophe
>
> --- In [email protected]
<mailto:flexcoders%40yahoogroups.com>  
> <mailto:flexcoders%40yahoogroups.com>, "Paul DeCoursey" <[EMAIL PROTECTED]>
wrote:
> >
> >
> > I was looking into this, because I wanted to do some IoC work in
Flex.
> > I found one issue, I don't have any reference for getClassByName adn
> > cannot compile when trying to use it. Was it removed? what's the
> > deal there?
> >
> > Anyway, one solution I had thought of was to use a ObjectFactory of
> > sorts. Then you pass in an array of arguments to a getInstance
> > function and it would use the correct call based on the length of
the
> > array. It would be more code but it would be hidden away in a
factory
> > class. If you need an example let me know.
> >
> > Paul
> > --- In [email protected]
<mailto:flexcoders%40yahoogroups.com>  
> <mailto:flexcoders%40yahoogroups.com>, "herrodius" <lists@> wrote:
> > >
> > > Hi guys,
> > >
> > > I'm looking for a way to dynamically invoke a constructor and pass
in
> > > arguments. I know this was possible in AS2 with
> > > Function.apply() on the constructor property of an object but I
didn't
> > > find anything in AS3.
> > >
> > > I found a 1-year old post from Matt Chotin that says it wouldn't
be
> > > possible in AS3, but I was kinda hoping it might have magically
> > > changed by now ;-)
> > > 
> http://www.mail-archive.com/[email protected]/msg21919.html
<http://www.mail-archive.com/[email protected]/msg21919.html>  
> <http://www.mail-archive.com/[email protected]/msg21919.html
<http://www.mail-archive.com/[email protected]/msg21919.html> >
> > >
> > > Any tips?
> > >
> > > thx,
> > > Christophe
> > >
> >
>
> 

 

Reply via email to