|Basic Programming Terminology:
• In flash, Action = Command.
• A command is a task that is directed at a target.
• Arguments are additional bits of information that assist the action. Arguments are also known as Parameters.
• An event is something that triggers an action or a set of actions.
-Actions react to events.
-An example of an (external) event would be a user pressing a key or clicking a button.
-An example of an (internal) event would be a counter keeping track of time.
• Events are paired up with event handlers.
• An event handler is a sequence of actions.
• Variables are named containers used to hold data, including data of different value types.
• A value type is the category of the thing that is in the variable (container).
-An everyday example would be a wallet, which is a container for money, which is the type of item in the wallet (not to be mistaken with the actual value of the money).
-A flash example: myVariable = 3; -myVariable is the container for the value type: integer.
• There are 3 different value types:
-strings, which can be as short as one character in length or as long as a whole sentence. They can contain a various combination of letters, numbers, and symbols.
-numbers, in the form of integers (negative and positive whole numbers: -1, 0, 1...) and floats (negative and positive decimal numbers: -1.2, 0.6, 1.8...).
-booleans, which are true or false. Booleans are like a switch, they are either on or off, true or false.
NOTE: Actionscript does NOT require a programmer to specify the value type of variables when declaring and initializing variables.
-in C, a declaration would look like this: float myVar = 2.3;
-in Actionscript, simply: myVar = 2.3;
• Variable values: Literal vs. Expressions
-Ex: myName = "laura"; -string (value type) literal
-Ex: myNum = 52; -numerical literal
-Using a literal value is also known as hard-coding.
• Expressions are sequences of literals and variables linked together by mathematical symbols.
-Ex: myVar = myNum + 13; (myVar = 52 + 13 = 65).
-Make sure when you have variables on both sides of the equal sign that they are the same value type. A string plus a string equals a string (same for numbers), but a string plus a number equals a string.
-Ex: myVar = myName + 13; (myVar = "laura" + 13 = "laura13").
• Things to remember when naming variables:
-don't use reserved words (delete, do, on, else, for, true, false, etc..), avoid math operators (+, -, *, /) and logic operators (&&, ||, !).
-don't use spaces, use an underscore (_): my_var;
-don't start a variable with a number: 3t - bad, t3 - good;
-do create names that are unique and descriptive: myAge, myName, etc..
-AS of MX 04 Actionscript IS case sensitive: bigdog does NOT equal BIGDOG.
• Arrays are data structures used to hold multiple pieces of information about a particular thing.
-An example of a use of an array would be a website that collects user information, such as, name, address, phone number, etc. Each item is a separate entity, but all three relate to the user that entered the info.
-Declaring an array without initializing it: myArray = new array();
-Two ways to declare and initialize an array:
myInfo = new Array("laura", "102 shaffer building, etc..", "444-4444");
myInfo = "laura";
myInfo = "102 shaffer building, etc..";
myInfo = "444-4444";
-The number inside the bracket is known as the index (position) of a particular piece of data. The index always starts with 0 as the first position. The index can be substituted with a variable, also: myArray[myVar] = 13;