O'Reilly logo

ActionScript: The Definitive Guide by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating and Categorizing Data

There are two ways to create a new datum with ActionScript, both methods requiring the use of expressions—phrases of code that represent data in our scripts.

A literal expression (or literal for short) is a series of letters, numbers, and punctuation that is the datum. A data literal is a verbatim description of data in a program’s source code. This contrasts with a variable, which is a container that merely holds a datum. Each datatype defines its own rules for the creation of literals. Here are some examples of literals:

"loading...please wait"  // A string literal
1.51                     // A numeric literal
["jane", "jonathan"]     // An array literal

Note that movie clips cannot be represented by literals, but are referred to by instance names.

We can also generate data programmatically with a complex expression. Complex expressions represent data as a phrase of code with a value that must be calculated or computed, not taken literally. The calculated value is the datum being represented. For example, each of these complex expressions results in a single datum:

1999 + 1       // Yields the datum 2000
"hi " + "ma!"  // Yields the datum "hi ma!"
firstName      // Yields the value of the variable firstName
_currentframe  // Yields the frame number of the playhead's current position
new Date( )     // Yields a new Date object with the current date and time

Notice that an individual literal expression like 1999 or 1 can be a valid part of a larger complex expression, as in 1999 + 1.

Whether ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required