Understanding the ActionScript Language > Creating functions > Using variables in a function |  |

Using variables in a function

Local variables are valuable tools for organizing code and making it easier to understand. When a function uses local variables, it can hide its variables from all other scripts in the movie; local variables are scoped to the body of the function and are destroyed when the function exits. Any parameters passed to a function are also treated as local variables.

You can also use global and regular variables in a function. However, if you modify global or regular variables, it is good practice to use script comments to document these modifications.