Amy,

Fotis is right--if you want to specify a param that has a default, you
need to specify all parameters to the left of it in the argument list.

Depending on your function and how many parameters it has, you may want
to add a class to represent your function arguments, construct that
object independently, and pass that to your function. E.g.,

var args:FunctionArgs = new FunctionArgs();
args.foo = 123;
args.bar = "baz";

theFunction(args);

This doesn't always make sense, but it can help.
-- 
Maciek Sakrejda
Truviso, Inc.
http://www.truviso.com

-----Original Message-----
From: Amy <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: [email protected]
Subject: [flexcoders] Calling functions with optional parameters
Date: Fri, 14 Nov 2008 21:12:16 -0000

I thought that when you have a function that looks like this:

private function theFunction(param1:int=0, param2:int=1, 
param3:String='foo') {
//do stuff
}

That it's ok to call the function like this:

theFunction(,,'bar');

But when I do this, I'm getting all sorts of syntax errors, 
including "Expecting identifier before comma." Am I misunderstanding 
how this works? Will I have to use ...rest and give up my typed 
arguments and named variables?

Thanks;

Amy




 


Reply via email to