- Arguments
- Function Parameters
- Public Attribute Keyword
- Private Attribute Keyword
- Defining Constants
Function Parameters
Function parameters are essentially the variable names of values that are passed into a function. Function parameters are fairly straightforward and have not changed in ActionScript until now.
AS2: Function Parameters
Parameters are a fundamental part of the function definition. ActionScript 2 allows parameter typing, meaning that parameters can be specified as any native type, such as String, Boolean, Number, and so on—or can even be typed as a custom object. Typing provides control and reliability of values allowed into a function and prevents bugs by providing detailed information about your code to the Flash compiler.
AS3: Function Parameters
Function parameters have always been a part of ActionScript. ActionScript 3 allows parameters to have default values, which essentially make them optional parameters. For example, if a parameter has a default value and a function call omits the parameter, the default value is used.
The optional parameter, named round, has a default value of false. The round parameter will remain false unless an alternate parameter value is passed in a function call. Therefore, the addNumbers sample function will not round the total it returns.