PDA

View Full Version : default parameters question



Stratboy
May 12th, 2008, 11:01 AM
Hi! Why can't I init my parameter with an object? Ex.

public static function createRect(opt = {x:0,y:0}){....

or

public static function createRect(opt:Object = new Object){....

It says:

1047: Parameter initializer unknown or is not a compile-time constant.

Groady
May 12th, 2008, 11:49 AM
Because you're trying to instantiate an object within the parameters of a method. Your methods should be looking to receive an already existing object or some rudimentary values (number, strings etc). Someone may need to clarify this in case I am missing something.