9
More Tips on Flash CSC361/661 Digital Media Spring 2007 Burg

More Tips on Flash CSC361/661 Digital Media Spring 2007 Burg

Embed Size (px)

Citation preview

Page 1: More Tips on Flash CSC361/661 Digital Media Spring 2007 Burg

More Tips on Flash

CSC361/661Digital MediaSpring 2007

Burg

Page 2: More Tips on Flash CSC361/661 Digital Media Spring 2007 Burg

Shape tweening

• You can tween more than one shape on a layer, but sometimes you get weird results.

• Example – stem and top of mushroom are separate objects. Using tweening, make it look like the mushroom is growing.

• On the second keyframe, the top is moved up. The bottom is deleted and replaced by a longer stem.

Page 3: More Tips on Flash CSC361/661 Digital Media Spring 2007 Burg

ActionScript

• Syntax very much like C and C++• Like Lingo, much of the programming

environment is inherently object-oriented. • You can make graphic objects and convert them

to symbols– Graphic– Buttons– Movie clips

• Then you make instances of symbols. So the symbols in the library are like classes.

Page 4: More Tips on Flash CSC361/661 Digital Media Spring 2007 Burg

Symbols

• Graphic symbols have their own timelines, but you have to have at least as many frames on the main timeline as on the graphic symbol’s timeline.

• Buttons have an independent timeline with up, down, over, and hit states.– You can animate the states with embedded movie clips if you

want.– You can add sound to a state.

• Movie clips have an independent timeline. You can embed movie clips in movie clips.– E.g., a car driving on stage. The wheels can be an embedded

movie clip.

Page 5: More Tips on Flash CSC361/661 Digital Media Spring 2007 Burg

Movie Clips and ActionScript

• You can give an instance name only to a movie clip.

• If a movie clip has a name, you can refer to it in ActionScript and do things with it dynamically.

• To add properties to a movie clip you can– Make the movie clip part of a class.– Add a property dynamically by assigning a value (Isn’t

that great?!!)• For example, KC.v = 10 adds an “instance variable” to hold

the value of a card. KC is a movie clip. Nowhere was this instance variable declared. It is just created dynamically.

Page 6: More Tips on Flash CSC361/661 Digital Media Spring 2007 Burg

Declaring variables

• You don’t have to declare variables and their types in ActionScript, but you can if you want to. For examplevar value:Number = 10;Var Array: deck = new Array();

• The advantages to declaring variables are– Type checking is done by the system, to help prevent

your making mistakes– Prompts come up telling you want properties or

functions are related to a variable.• To get hints for movie clips, you have to add

_mc to the variable name.

Page 7: More Tips on Flash CSC361/661 Digital Media Spring 2007 Burg

Action Pane and Script Pane

• You can see Global Functions and functions that you can use with movie clips in the Actions pane.

• You can doubleclick on a function name and it gets inserted into the script.

• You can also type things in yourself.

Page 8: More Tips on Flash CSC361/661 Digital Media Spring 2007 Burg

Object-Oriented

•Use a text editor to type a class definition into a text file, with suffix .as•The text file should have the same name as the class and be in the same folder as the .fla program.Class Dog {var name: String;var weight: Numbervar bark: String;function Dog(name:String, weight: Number, bark: String) {

this.name = name;this.weight = weight;this.bark = new Sound();this.bark.attach(bark); }

}

Page 9: More Tips on Flash CSC361/661 Digital Media Spring 2007 Burg

Where do you put the code?

• First frame of action layer.

• On a button or movie clip.

Etc.