Flash CS3 Documentation |
|||
| Learning ActionScript 2.0 in Adobe Flash > Syntax and Language Fundamentals > About language punctuators > Parentheses | |||
When you define a function in ActionScript, you place parameters inside parentheses [()] punctuators, as shown in the following lines of code:
function myFunction(myName:String, myAge:Number, happy:Boolean):Void {
// Your code goes here.
}
When you call a function, you also include any of the parameters you pass to the function in parentheses, as shown in the following example:
myFunction("Carl", 78, true);
You can use parentheses to override the ActionScript order of precedence or to make your ActionScript statements easier to read. This means you can change the order in which values are computed by placing brackets around certain values, as seen in the following example:
var computedValue:Number = (circleClip._x + 20) * 0.8;
Because of order of precedence, if you didn't use parentheses or use two separate statements, the multiplication would be computed first, meaning that the first operation would be 20 * 0.8. The result, 16, would then be added to the current value of circleClip._x and finally assigned to the computedValue variable.
If you don't use parentheses, you must add a statement to evaluate the expression, as shown in the following example:
var tempValue:Number = circleClip._x + 20; var computedValue:Number = tempValue * 0.8;
As with brackets and braces, you need to make sure each opening parentheses has a closing parentheses.
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00000688.html