My original suggestion was bogus...revoked.
Message was edited by: CoreyRLucier
I think what Dave is asking is a bit different.
He's wanting to know how to invoke the constructor of an object dynamically (when he only knows the # of constructor arguments at runtime).
This class I know will do it but seems to be a hack:
See the 'call' method, which first counts the # of arguments then invokes one of 'n' construction methods based on the number of constructor args.
I've yet to find a clean AS3 way of doing things ala 'call' though.
Hi Corey, thanks for the excellent reference!
I can accept this 'hack' as you say as a viable solution in my case. Since the set of potential classes to instantiate is known at compile time it's perfectly safe to use this approach as I can guarantee that no constructor will have more than 15 arguments (or I can extend the class as necessary in such an unlikely event).
I'll leave the question open for another day in case anyone else has any input, but I think this'll solve my problem!
1 person found this helpful
I've confirmed with the Actionscript team that there isn't a means of doing what you wish currently in AS3.
Hi, thanks for following up on this.
I've got everything working quite nicely with the technique you pointed me towards, so I'm happy enough using this method.