Variables Using Strict Data Typing
Flash MX 2004 and 8 1. A variable is a holder for a value. A
variable is like a coffee cup where it can hold the value for the variable. It may be empty, contain a "cup of
Columbian coffee" (string), 50 pennies (number), or paperclips, pushpins, and pennies (an array). There are three types of value holders or variables.
- A Number is strictly digits
- A Sting is any combination of characters, including letters and/or numbers. The value is usually seen written in quotes "this is a string". The quotes mean a literal interpretation of the value, or string.
- An Array is a set of values. This can be a set of variables, movie clips, information, coordinates and more.
2. You can specify if a variable is holding a number, a string or an array, Using this format will set the variable type until you change it. If your variable name is myVariable, then you can
specify the following:
| Number |
var myVariable:Number = 25; |
| |
|
| String |
var myVariable:Number = "some string value"; |
| |
|
| Array |
var myVariable:Array = newArray(); |
| |
|
|