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

Reply via email to