I'm curious to hear a little more about what you guys are trying to do.

Nate, I noticed in your class file that there is a space between ... and
args. I think it's supposed to be ...args

On Fri, Jan 9, 2009 at 3:24 PM, Patrick Matte | BLITZ <
pma...@blitzagency.com> wrote:

> I see, thanks for your answer, I also feel dirty doing that! But at least
> it works, it could have been worse...
>
> -----Original Message-----
> From: flashcoders-boun...@chattyfig.figleaf.com [mailto:
> flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Nate Beck
> Sent: Friday, January 09, 2009 11:33 AM
> To: Flash Coders List
> Subject: Re: RE : [Flashcoders] create object with getDefinition and pass
> parameters using apply ?
>
> Hey Patrick,
> I've run into the exact same issue that you have.  Actionscript doesn't
> support overloaded methods or constructors at this time, although there is
> talk that they are going to add that support at some point in the future.
>
> I have not to this day, found a way to use the apply method on a
> constructor.
>
> I'm working on a DateTime class that can proxy for a Date class.  I had to
> do something very similar to what you're doing:
>
> http://natebeck.net/swag/trunk/src/net/natebeck/core/DateTime.as (Look at
> the constructor)
>
> I've even tried something like this:
>
> _date = new Date(... args); // <----- Make this work, please :D
>
>
> But I get an interesting error: 1199 : RestExpressionNode not yet
> implemented.
>
> Another train of thought would be to do something very similar to a
> singleton pattern.  Instead of using the constructor, always call a method.
>
>
> myClass.getInstance().doSomething().
>
> But that still doesn't solve the creation of a class with n-number of
> parameters.
>
> I understand what you're trying to do, I just haven't found a good way to
> do
> it yet. If you figure something out, be sure to let me know!
>
> Cheers,
> Nate
>
> On Thu, Jan 8, 2009 at 9:39 PM, Patrick Matte | BLITZ <
> pma...@blitzagency.com> wrote:
>
> > That wouldn't help, I'm writing a class that can create any kind of
> objects
> > and pass any number of argument to that object at instantiation.
> >
> > ________________________________________
> > De : flashcoders-boun...@chattyfig.figleaf.com [
> > flashcoders-boun...@chattyfig.figleaf.com] de la part de Joel Stransky [
> > stranskydes...@gmail.com]
> > Date d'envoi : 8 janvier 2009 20:28
> > À : Flash Coders List
> > Objet : Re: [Flashcoders] create object with getDefinition and pass
> > parameters using apply ?
> >
> > Why not predefine the params as null?
> >
> > class myClass{
> >  public function myClass(param1 = null, param2 = null, ... param6 =
> null){
> >  }
> > }
> >
> > or just use the rest (...) parameter
> >
> > class myClass{
> >  public function myClass(...args){
> >    for(var i:uint = 0; i < args.length; i++){
> >      trace(args[i]);
> >    }
> >  }
> > }
> >
> > On Thu, Jan 8, 2009 at 10:36 PM, Patrick Matte | BLITZ <
> > pma...@blitzagency.com> wrote:
> >
> > > Well for now I've done this which supports up to 5 arguments but if
> > > anyone's got a better suggestion please tell me...
> > >
> > > var classReference:Object = getDefinitionByName(className);
> > > var object:Object;
> > > switch(array.length) {
> > >        case 0:
> > >                object = new classReference();
> > >        break;
> > >        case 1:
> > >                object = new classReference(array[0]);
> > >        break;
> > >        case 2:
> > >                object = new classReference(array[0],array[1]);
> > >        break;
> > >        case 3:
> > >                object = new classReference(array[0],array[1],array[2]);
> > >        break;
> > >        case 4:
> > >                object = new
> > > classReference(array[0],array[1],array[2],array[3]);
> > >        break;
> > >        case 5:
> > >                object = new
> > > classReference(array[0],array[1],array[2],array[3],array[4]);
> > >        break;
> > > }
> > >
> > > -----Original Message-----
> > > From: flashcoders-boun...@chattyfig.figleaf.com [mailto:
> > > flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Patrick
> > > Matte|BLITZ
> > > Sent: Thursday, January 08, 2009 7:19 PM
> > > To: Flash Coders List
> > > Subject: [Flashcoders] create object with getDefinition and pass
> > parameters
> > > using apply ?
> > >
> > > I need to create objects using getDefinition and pass parameter to the
> > > constructor but the problem is that the number of parameters can be
> > > different. I tried using apply like this but I can't make it work.
> > >
> > > var classReference:Object = getDefinitionByName(className);
> > > var object:Object = new classReference.apply(this, array);
> > >
> > > Is there any way to do this ?
> > >
> > > _______________________________________________
> > > Flashcoders mailing list
> > > Flashcoders@chattyfig.figleaf.com
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> > > _______________________________________________
> > > Flashcoders mailing list
> > > Flashcoders@chattyfig.figleaf.com
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> >
> >
> >
> > --
> > --Joel Stransky
> > stranskydesign.com
> > _______________________________________________
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> > _______________________________________________
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
>
>
>
> --
>
> Cheers,
> Nate
> ----------------------------------------
> http://blog.natebeck.net
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



-- 
--Joel Stransky
stranskydesign.com
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to