Foundation ActionScript Animation
12 comments | Posted: 30 January 06 in Books, by Nathan Smith
I just finished reading through Foundation ActionScript Animation, and all I can say is: Wow. Remember as a kid when your math teachers told you that you’d be able to actually use all that stuff someday? They weren’t joking. Keith Peters has jam-packed this book with just about everything you’d need to know in order to animate things in Flash using pretty much pure ActionScript code.
One of my coworkers told me this book was going to be good, having only seen the author’s name. They had each contributed to the book Byte Sized Flash several years ago. From the listing on Keith’s site, he’s been incredibly busy writing books since then. I was completely mezmorized by some of the things possible in Flash today, and appreciated the straightforward style of the text.
If the reference to math scared you off, you’re in good company. I always loved the spatial reasoning aspects of math classes, but never much cared for the word problems. I mean, if two trains are passing each other, why do we need to know the exact time at which they pass? Clearly they’re not going to hit each other, and you don’t have enough time to wave to anyone as they zip by!
My point is, the author makes you aware early on that ActionScript is more visual than it is verbal. He says it best on page 42:
The funny thing is that in programming with trigonometry, you are hardly dealing with numbers at all. It’s far more in the realm of visualizing shapes and relationships.
I can attest that most of the book is about how to set up your ActionScript with variables, so that you can easily manipulate your effects based on entering a few values once the rest of the code is in place. Think of it as the way that CSS is used to separate presentation from structural markup. We plug in our numerical values to a value-less code snippet based on ratios / rhythm, and then it springs to life. That’s a little over-simplified, but you get the point.
I even learned some new jargon to throw around the office. For instance, did you know that a twip is the word for 1/20th of a pixel? Yeah, me neither. This is how intricately Flash calculates movement and positioning, at a sub-pixel level.
In earliest chapters, Keith covers the basics of drawing shapes and creating movements, but it’s in the later chapters that this book really shines. He delves into the tenets of physics, and how to mimick these aspects in Flash. On page 237, he gives a great explanation of mass, velocity and momentum…
“Something with a small mass and high velocity could have a similar momentum to something with a large mass and low velocity. [A] large truck moving at a mere 20 miles per hour could easily kill you. A bullet, on the other hand, has a relatively tiny mass but a much higher velocity, and it’s just as deadly.
By far my favorite chapter was 16. You may or may not know that while in college, I made several video game levels for first-person shooters (screenshot). This chapter took me back. It shows how to create complex polygons, via floating point defenitions, matricies and mimicking extrusion.
If you’ve done any sort of 3D modeling / game mapping, you will know what I mean. If not, then take a look at this picture of an old Superman comic. Normally, text is 2D, but py “smearing” or pushing it out, that is an extrusion. You could think of it like many paper snowflakes stacked on top of each other.
He also shows how to cut up surfaces, called “cleaving” in gaming lingo. Basically, it’s a way of choosing existing points on an object, and then passing straight lines through to other points. Eventually, you have an object comprised entirely of triangles. Since this is nature’s most simple 2D form, it is the most efficient way for a computer to render surfaces in a psuedo 3D environment. When you see a video card on sale, and it boasts how many polygons it can draw on-screen per second, this is the measure to which they are referring.
Anyway, I could go on and on, but as was mentioned earlier, the biggest appeal of this book is the wealth of code examples, and the down to earth writing style. He takes large problems and by chunking them into smaller ones, helps you to logically progress from wondering “what if” to actually realizing the solution in code. In the author’s own words from the intro…
This book’s greatness has nothing to do with my writing ability, personality, or anything else about me. I consider it great because of the subjects it covers. This is the book I’ve been looking for since 1999. If someone else had written it back then, I would have bought it, read it, and called it a great book, and that would be the end of the story. But since nobody seemed to be stepping up to the task, I decided to do it myself.
I don’t think he gives himself enough credit. Yes, this is a great book, but I think it’s largely because Keith Peters is a great author. Suffice it to say, I’m glad he stepped up to the task to write such a thorough guide to ActionScript.
Discuss This Topic
Comments closed after 2 weeks.