ryanSmithART.com/courses/363/2014


- - Variables & Data Types - -

ryansmithart.com/courses/363/2014



"Variables are best described as containers into which you place information for later recall...
In basic terms, you need only create a variable with a unique name, so it can be referenced separately from other variables... "
A simple example is remembering the number 1 with the following:
myVariable = 1;

Rules for naming variables:
-must be one word
-can only include alphanumeric characters, or $, or _
-should not start with a number
-should not already be a keyword or reserved for ActionScript

"...Flash must be told what you intend to store in each variable."

Example:
var variableName(colon)dataType;
or
var myVariable:int;

Variable Types:
Data Type Example Description
Number 4.798 Any number, including decimals
int -4 Any integer or whole number
uint 1 Unsigned integer or any non-negative whole number
String "hello" Text or string of characters
Boolean true True or False
Array [2, 9, 17] More than one value in a single variable
Object myObject "The basic structure of every ActionScript entity, but also a custom form that can be used to store multiple values as an alternative to Array."

"In previous versions of ActionScript, declaring and typing variables was optional.
However, in ActionScript 3.0, this practice is required."

From Learning ActionScript 3.0, by Rich Shupe & Zevan Rosser (pages: 16 & 17)