Understanding the ActionScript Language > Creating functions > Passing parameters to a function |  |

Passing parameters to a function

Parameters are the elements on which a function executes its code. (In this manual, the terms parameter and argument are interchangeable.) For example, the following function takes the parameters `initials` and `finalScore`:

    function fillOutScorecard(initials, finalScore) {
    	scorecard.display = initials;
    	scorecard.score = finalScore;
    }

When the function is called, the required parameters must be passed to the function. The function substitutes the passed values for the parameters in the function definition. In this example, `scorecard` is the instance name of a movie clip; `display` and `score` are input text fields in the instance. The following function call assigns the value `"JEB"` to the variable `display` and the value `45000` to the variable `score`:

    fillOutScorecard("JEB", 45000);

The parameter `initials` in the function `fillOutScorecard` is similar to a local variable; it exists while the function is called and ceases to exist when the function exits. If you omit parameters during a function call, the omitted parameters are passed as `undefined`. If you provide extra parameters in a function call that are not required by the function declaration, they are ignored.