39542 Web Animation

Spring 2007 Semester | Mondays 6:15 p.m. to 9:05 p.m.
Professor Rich Hauck
Department of Art
The City College of New York
richardhauck [at] hotmail

Classes

Why Use ActionScript?

In addition, ActionScript (AS) is similar to other programming languages in syntax (or structure), so after learning AS code, you'll be able to slightly recognize other programming languages.

Flash Interface

One of the greatest tips I can provide is also one of the easiest, though it is often overlooked. If at anytime you don’t know what a reserved keyword (usually highlighted in blue) in the ActionScript palette means, highlight the word and hit the help button. This will bring up the extensive and well-documented ActionScript reference that provides in-depth descriptions and code examples.

help

If you wish to explore the structure of the language, you can always hit the plus button in the upper left of the palette. This will show the hierarchy of ActionScript code.

flash AS menu

Strict Data Typing and Creating Code Shortcuts

Strict Data Typing is a way to ensure that a variable remains the same type of variable from when it has been created to when it is assigned a new variable. This creates more readable code and as an added benefit generates code hints (You can also create code hints through naming conventions, Example: naming MovieClip instances with “_mc” appended will create hints in the ActionScript).

In the past, you would create a variable in Flash by simply declaring:

// create a number variable
var myNumber = 10;

or

// create a number variable
myNumber = 10;

With ActionScript 2.0’s strict data typing, a variable would be declared as

// create a number variable
var myNumber:Number  = 10;

As a result, assigning the variable anything other than a number at a later time would generate a compiler error.

// assign a String type to myNumber
myNumber = “This is a String”; // this would run an error.

Variable, Function, and Object Naming Conventions

ActionScript Examples

Download Button Example Flash (ZIP)

Download Variable Example Flash (ZIP)

Download onEnterFrame Example Flash (ZIP)