> This code is similar to "var a:* = new A(1,2,3);" in my original
> post. Arguments count is statically specified at compile time.
> But I am looking for the way to pass different number of arguments
> to constructor at runtime. Arguments type and count are unknown at
> compilation time, that is why someArgs:Array used.
> Flex 1.5/AS2 implements class constructor as AS2 Function object and
> we were able to call it like Function.apply(context, args). Now we
> are looking for something similar in AS3...
Unfortunately there isn't any similar functionality in AS3, I asked
the same question a few weeks ago and requested an additional method
in the new Class class:
public function newInstance (constructorArgs:Array) : Object
So that I could write:
function createInstance (className:String, args:Array) : Object {
var MyClass:Class = getClassByName(className);
return MyClass.newInstance(args);
}
But unfortunately the answer from someone from Adobe was: Since it
isn't in the ECMA-4-spec they will not include it.
There are some corner cases like this (and the prevention of private
and protected constructors) where AS 3 actually is a step back from
AS 2...
Jens
www.oregano-server.org
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/