Understanding the ActionScript Language > Using ActionScript syntax > Parentheses

 

Parentheses

When you define a function, place any parameters inside parentheses:

function myFunction (name, age, reader){
	...
}

When you call a function, include any parameters passed to the function in parentheses, as shown here:

myFunction ("Steve", 10, true);

You can also use parentheses to override the ActionScript order of precedence or to make your ActionScript statements easier to read. (See Operator precedence.)

You also use parentheses to evaluate an expression on the left side of a dot in dot syntax. For example, in the following statement, the parentheses cause new Color(this) to evaluate and create a new Color object:

onClipEvent(enterFrame) {
	(new Color(this)).setRGB(0xffffff);
}

If you didn't use parentheses, you would need to add a statement to evaluate the expression:

onClipEvent(enterFrame) {
	myColor = new Color(this);
	myColor.setRGB(0xffffff);
}