Foundation ActionScript Animation: Making Things Move!

Front Cover
Apress, Nov 22, 2006 - Computers - 400 pages

Sure you can animate using motion tweens—in fact, we’ll help you do that with our Flash Cartoon Animation book—but isn’t there something extra special in making things move with just a few lines of code?

In this book Keith Peters guides you through some basic animation theory and then demystifies the math and physics behind creating realistic animation, looking at trigonometry, velocity and acceleration, and bouncing & friction.

This book will teach you how to use Flash ActionScript to move the objects in your movies, rather than letting Flash's tween engine do it for you. The benefit of this is smaller, more realistic, more dynamic interactive movies that seem to come alive on your screen. Almost all of the code featured in this book will work fine in either Flash MX 2004 or Flash 8, and with a few minor adjustments, most of it can even be applied to Flash MX.

Although the text covers many advanced math and physics concepts, making for very realistic motion, there’s no need to worry, even if you're a relative newcomer to programming and the last math class you took was in high school (and even if you barely remember that!).

This book first covers everything you need to know to get started: the principles of animation, and the basics of ActionScript, trigonometry, and Flash rendering methods. You’ll work your way through slowly, from using code to move a single object across the screen to creating complex systems that really push Flash's capabilities, with topics covered including collision detection, particle attraction, and kinematics. The book concludes with looking at 3D animation techniques, including building a basic 3D engine, 3D lines, fills and solids, and matrix math.

Once you come to grips with the ideas presented here, you'll find yourself creating all manner of exciting animations and games!

 

What people are saying - Write a review

We haven't found any reviews in the usual places.

Contents

Multipleobject collision detection strategies
204
Multipleobject springing
206
Important formulas in this chapter
211
COORDINATE ROTATION AND BOUNCING OFF ANGLES
214
Simple coordinate rotation
215
Advanced coordinate rotation
216
Rotating a single object
217
Rotating multiple objects
218

Looping
16
Frame loops
20
Clip events
21
Flash MX events and event handlers
24
Listeners
25
Handlers
26
Events for animation
28
Movie clips
29
Movie clip symbols and instances
30
Creating empty movie clips
33
A basic class
34
Constructors
35
A MovieClip subclass
36
User interaction
37
Keyboard events
38
Mouse position
39
Summary
40
TRIGONOMETRY FOR ANIMATION
42
What is trigonometry?
43
Radians and degrees
44
Flashs coordinate system
45
Triangle sides
48
Cosine
50
Tangent
51
Arcsine and arccosine
52
Rotation
54
Waves
56
Smooth up and down motion
58
Linear vertical motion
59
Waves with two angles
60
Circles and ellipses
61
Elliptical movement
63
Distance between two points
64
Important formulas in this chapter
66
Summary
68
RENDERING TECHNIQUES
70
Colors in Flash
71
Combining colors
72
Extracting component colors
74
Removing drawing with clear
75
Setting line appearance with lineStyle
76
Drawing curves with curveTo
78
Curving through the control point
79
Creating shapes with beginFill and endFill
83
Creating gradient fills with beginGradientFill
84
Creating the matrix
85
Color transforms
88
Transforming colors with setTransform
89
Changing colors with the ColorTransform object
90
Filters
92
Creating a filter
93
Animating filters
94
Bitmap control
95
Important formulas in this chapter
98
Summary
99
Part Two
100
VELOCITY AND ACCELERATION
102
Velocity
103
Velocity on one axis
105
Velocity on two axes
106
Vector addition
108
A mouse follower
109
Acceleration
110
Acceleration on one axis
111
Acceleration on two axes
113
Gravity as acceleration
114
Angular acceleration
116
A spaceship
117
Ship controls
119
Thrust
120
Important formulas in this chapter
121
Summary
122
BOUNDARIES AND FRICTION
124
Environmental boundaries
125
Removing objects
127
Regenerating objects
131
Screen wrapping
133
Bouncing
135
Friction
140
Friction the right way
141
Friction the easy way
142
Friction applied
143
Important formulas in this chapter
145
Summary
146
USER INTERACTION MOVING OBJECTS AROUND
148
Pressing and releasing a movie clip
149
Dragging a movie clip
151
Dragging with mouseMove
152
Dragging with startDragstopDrag
153
Throwing
157
Summary
160
Part Three
163
EASING AND SPRINGING
165
Proportional Motion
166
Simple easing
167
When to stop easing
170
A moving target
172
Easing isnt just for motion
173
Colors
174
Springing in one dimension
175
Springing in two dimensions
177
So wheres the spring?
178
Chaining springs
179
Springing to multiple targets
182
Offsetting the target
184
Attaching multiple objects with springs
185
Important formulas in this chapter
188
Summary
189
COLLISION DETECTION
191
Collision detection methods
192
Hit testing two movie clips
193
Hit testing a movie clip and a point
196
Hit testing with shapeFlag
197
Summary of hitTest
198
Simple distancebased collision detection
199
Collisionbased springing
201
Bouncing off an angle
220
Performing the rotation
223
Optimizing the code
225
Making it dynamic
227
Bounds checking
228
Fixing the under the line problem
229
Bouncing off multiple angles
231
Important formulas in this chapter
236
BILLIARD BALL PHYSICS
239
Mass
240
Momentum
241
Conservation of momentum on one axis
243
Placing the objects
245
Optimizing the code
246
Conservation of momentum on two axes
247
Writing the code
251
Adding more objects
260
Solving a potential problem
262
Important formulas in this chapter
264
Summary
265
PARTICLE ATTRACTION AND GRAVITY
267
Particles
268
Gravity
269
Collision detection and reaction
272
Orbiting
273
Springs
274
A springy node garden
276
Nodes with connections
278
Nodes with mass
281
Important formulas in this chapter
283
FORWARD KINEMATICS MAKING THINGS WALK
286
Introducing forward and inverse kinematics
287
Getting started programming forward kinematics
288
Moving two segments
290
Automating the process
291
Building a natural walk cycle
292
Making it dynamic
295
Making it really walk
297
Adding gravity
298
Handling the collision
299
Handling the reaction
301
Screen wrapping revisited
304
Summary
308
INVERSE KINEMATICS DRAGGING AND REACHING
311
Reaching and dragging single segments
312
Dragging with a single segment
313
Dragging multiple segments
314
Dragging more segments
315
Reaching with multiple segments
316
Reaching for an object
320
Adding some interaction
322
Using the standard inverse kinematics method
323
Introducing the law of cosines
324
ActionScripting the law of cosines
326
Important formulas in this chapter
328
Part Four
329
3D BASICS
331
The third dimension and perspective
332
Perspective
334
Perspective in ActionScript
335
Velocity and acceleration
338
Bouncing
339
Multiple object bouncing
342
Zsorting
344
Wrapping
347
Easing and springing
353
Springing
354
Coordinate rotation
356
Collision detection
361
Important formulas in this chapter
363
3D LINES AND FILLS
365
Creating points and lines
366
Making shapes
369
Creating 3D fills
373
Using triangles
374
Defining the triangles colors
379
Modeling 3D solids
380
Modeling other shapes
383
Extruded letter A
384
Cylinder
386
Moving 3D solids
388
Summary
391
BACKFACE CULLING AND 3D LIGHTING
393
Backface culling
394
Depth sorting
400
3D lighting
406
Summary
416
Part Five
417
MATRIX MATH
419
Matrix basics
420
Matrix addition
421
Matrix multiplication
422
Coordinate rotation with a matrix
423
Coding with matrices
424
The Matrix class in Flash 8
427
Summary
431
TIPS AND TRICKS
433
Brownian random motion
434
Random distribution
437
Circular distribution
439
Biased distribution
441
Interval and timerbased animation
444
Intervalbased animation
445
Timerbased animation
447
Collisions between samemass objects
449
Integrating sound
450
Useful formulas
453
Chapter 4
454
Chapter 5
455
Chapter 8
457
Chapter 9
459
Chapter 11
460
Chapter 14
461
INDEX
464
Copyright

Other editions - View all

Common terms and phrases

Popular passages

Page xv - ABOUT THE COVER IMAGE DESIGNER Corne van Dooren designed the front cover image for this book. Having been given a brief by friends of ED to create a new design for the Foundation series, he was inspired to create this new setup combining technology and organic forms. With a colorful background as an avid cartoonist, Corne discovered the infinite world of multimedia at the age of 17 — a journey of discovery that hasn't stopped since. His mantra has always been "The only limit to multimedia is the...
Page 4 - ENCOURAGE. 4. To inspire to action : PROMPT. 5. To impart motion or activity to. 6. To make, design, or produce (eg, a cartoon) so as to create the illusion of motion.
Page xv - ... magazines, testing software, and working on many other friends of ED books — Corne decided it was time to take another step in his career by launching his own company, Project 79, in March 2005. You can see more of his work and contact him through www.cornevandooren.com or www.project79.com.
Page xv - The only limit to multimedia is the imagination," a philosophy that is keeping him moving forward constantly. After enjoying success after success over the past years — working for many international clients, as well as being featured in multimedia magazines, testing software, and working on many other friends of ED books — Corne decided it was time to take another step in his career by launching his own company, Project 79, in March 2005. You can see more of Corne's work and contact him through...

About the author (2006)

Keith Peters lives in the vicinity of Boston with his wife, Kazumi, and their daughter, Kristine. He has been working with Flash since 1999, and has co-authored many books for friends of ED, including Flash MX Studio, Flash MX Most Wanted, and the ground-breaking Flash Math Creativity. In 2001, he started the experimental Flash site, BIT-101 (BIT-101.com), which strives for a new, cutting edge, open-source experiment each day. The site won an award at the Flashforward 2003 Flash Film Festival in the Experimental category. In addition to the experiments on the site, there are several highly regarded Flash tutorials which have been translated into many languages and are now posted on web sites throughout the world. Keith is currently working full time doing freelance and contract Flash development and various writing projects.

Bibliographic information