Action Scripting 3.0 | Alejandra Jarabo |
Media Arts & Technologies. Santa Barbara City College |
PROGRAMING CONCEPTS |
FUNCTIONS | ||||||||||||||||||||
FUNCTIONS are reusable blocks of code stored under a name, that are easy to be called back in Action Scripting. For absolute beginners, you´ll recognize a function because of the pair of parenthesis right after the name. |
||||||||||||||||||||
WRITING A CUSTOM FUNCTION | ||||||||||||||||||||
The name of the function should be oneword with no spaces, easy to remember or identify later. The first letter always in lowercase (you may have capitals through the name, like in many Action Script terms). If the name of the function turns blue after you type it, that word is already used by flash as a keyword and cannot be used as a function name. Remember: since you invent the name of the function, it will always show up in black. Only Flash terms show up in blue.
After that, you can list the tasks the function will perform(one or more lines of code), within the opening and closing brace.
See the function integrated in the button's code. Please visit the "How to program a button" page after you finish this page. LINK
|
||||||||||||||||||||
CALLING A CUSTOM FUNCTION | ||||||||||||||||||||
Later in the code, when you want the function to run again, you will type the name of the function and then the pair of parenthesis, with the semicolon for end of the line. (this is how you simplify the job: by not having to always write down the whole task the function contains) If I have already DECLARED a function called playBlueMovie, Y will call it in the code by just writing its name followed by parentlesis:
|
||||||||||||||||||||
WHAT ARE METHODS IN FLASH | ||||||||||||||||||||
Flash has organized commonly used tasks inside ¨pre-built functions¨ that you constantly use in Action Script. Examples of methods: Some methods don´t need any extra information to run, like play() or stop() See some different parameters the method gotoAndPlay can use:
| ||||||||||||||||||||