GDT 260 Animation for the Web: Fall 2003

Notes & Handouts October 15

Intelligent Actions

Remember:

Communication Between Symbols

With actionscript, symbols can tell each other what to do using dot notation.

You must name the instance of the movie clip you wish to control on the Properties panel. This is called instantiation.

Dot notation looks like: instanceName.action(), ie., square.play();. Dot notation is basically a path to the movie clip using dots rather than slashes, followed by the action. Paths to nested movie clips can be combined: parentInstanceName.childInstanceName.stop();.

Remember that all instances of a symbol are tied to the symbol in the library. When modifying the symbol in the library, changes apply to all instances of that symbol. But, we can change the attributes of instances, including:

Variables and Conditional Structures

Variables

Variables are simply named storage units that hold some value, sort of a cubbyhole with a name on it. The value of variables can stay constant, or it can change.

There are two types of variables in Flash:

Conditional Statements

Allows Flash to make a choice. If some condition is true, do this. If it’s not true, don’t do anything.

Example: If my name="Chris", say "Hi Chris", or else, say "Hi there"

Generally, if statements evaluate whether or not a variable meets a certain condition. If it does, we tell it to do one thing. If it doesn’t, we have the option of telling it to do something else, or nothing at all.

if (name=="Chris") {
    say("Hi Chris");
} else {
    say("Hi there");
}

Note that a double equals ( == ) tests for equality, whereas a single equals sign ( = ) sets equality.

Exercises

  1. Make a movie that counts and constantly displays the number of times a button has been clicked
    • You'll need to create a dynamic text field for this to work. Use the text tool, go to the Text Options palette, and select “Dynamic Text” from the dropdown menu. Give the text field a variable name like “clicks”
    • If you want a 0 to display in your text field before the button has been clicked, you'll need to set your variable to 0 in frame 1, and stop the timeline from playing.
  2. Modify that movie to only update the counter display when a second button is pressed (Hint: You'll need two variables)