Paul Robertson's words, punctuated

Thoughts on development, user-centered design, code, etc. by Paul Robertson

Book Review: Foundation ActionScript Animation

To begin, I’ve been a longtime fan of the work of Keith Peters, the author of this book. He is a well-known Flash developer, particularly for his ActionScript animation. For years he’s given away examples on his web site; however, I’ve always found it to be a bit of work to dissect his examples and figure out how and why they work the way they do. So frankly my biggest reason for wanting to read this book was the hope that I would get insight into “how Keith Peters thinks.”

Book summary

This book is an in-depth look at the topic of scripted animation in ActionScript. By “scripted animation” I mean making objects move using ActionScript, as opposed to the traditional approach of creating animation using the Flash timeline. The primary focus of the book is on creating animation for simulating real-world physics: making things move; simulating bouncing, gravity, springing, and friction; creating objects you can “throw,” and so on. Finally, an additional section gives an introduction to basic 3-D concepts and techniques. Most of the well-known and engaging Flash content uses these techniques; although they are particularly geared towards use in games and physics simulations. Since this book focuses on a specific application of ActionScript, it is definitely not a basic book or an introduction to ActionScript in general – I think that a good understanding of ActionScript syntax is essential to understand this book.

What I liked best

This book is well-written in terms of the sequence and clarity of the examples. He starts out explaining the basic principles (mostly trigonometry formulas) which underly the different animation behaviors. For the most part this is done in a clear, easy to understand way, even if you haven’t studied math for several years (like me) – all his examples are of common uses of the formula in ActionScript, and he’s quick to point out which formulas you’ll use all the time and which ones you’ll use less frequently.

I found the way he ordered the content, and the examples within each section, to be particularly helpful. Most topics build on the previous one, with clear and obvious connections between them. After a few chapters I found myself “thinking like Keith Peters” – or at least that’s how I described it to myself. For instance, at one point he explains the principle of acceleration, and how to apply it, tying it back concretely to the earlier discussion on basic trig principles. A few sections later he introduces the topic of gravity, which, he points out, is really just a form of acceleration. This made the sections easy to follow, and very shortly I was reading explanations of how to create advanced effects that have wowed me for years, and I was not only understanding the code that creates the effect, but also the underlying principles behind the code. By the middle of the book, I even found myself predicting which basic principles could be used to create other advanced effects; something that made me realize that this book not only was teaching me the basic principles and several common effects, but more importantly, how to apply the principles to create other effects which aren’t necessarily explained in detail in the book.

Room for improvement

No book is perfect, of course, as any author will likely admit. These are the most noteworthy problems I found with this book. But let me say up front that I think the book is well-written enough and in-depth enough that it is worth owning in spite of these specific shortcomings.

Narrow example domain

I can’t complain too much about this one, but the examples both in code and in concepts in the book are almost entirely focused on creating video games in Flash. However, I think it’s much more common to use these techniques for other things like user interface effects, something which (as far as I remember) wasn’t even mentioned in the book. Admittedly, the video game and physics simulation examples are certainly more clear and obvious, but I think it would have been nice to at least have a few examples of things like an animated menu, a window that flies into view, or something from a different type of application other than video games.

Unnecessary basic concepts

In the introductory portions of the book, Keith faces the typical book-author dilemma of “what should I assume is the prior knowledge of the reader.” The book includes a couple of sections introducing basic ActionScript concepts such as functions and event handlers. However, I think those sections are ones he should have just left out completely – the quick summary treatment isn’t enough to really teach those concepts well if somebody doesn’t already have experience with them, and it’s just annoying filler for the reader who does already know what those things are. I think if anyone is to the point in their ActionScript experience where they are really ready for this book, they should already have a good grasp on functions and event handlers. Interestingly, he doesn’t explain other syntactic structures like loops and conditional statements at all.

ActionScript version confusion

One of the stated goals of the way the code is written is that “it will work in ActionScript 2.0, and with few or no changes it will work in ActionScript 1 also.” I disagree with this choice; I think at this point (two and a half years after the introduction of AS2, with ActionScript 3 already in the public eye) I don’t think there’s a very good reason to cater to the ActionScript 1 audience. Don’t get me wrong; I still see job postings which specify “knowledge of AS1” as a requirement, so I know it’s not obselete, but the differences are small enough (at least for the examples in this book) that I think it would have been better to just write the examples in pure AS2, and let people who need the code in AS1 work out the differences, especially since teaching AS1 isn’t a stated goal of the book.

Unfortunately what you get instead is that the code examples contain a mx of AS2 and AS1, without any real reason for doing so (other than, I assume, because that is the author’s personal style). For example, consider this (abbreviated) code listing from the book:

function init():Void
    force = 0.5;
    vx = 0;
    vy = 0;
function onEnterFrame():Void
    var dx:Number = _xmouse - arrow._x;
    var dy:Number = _ymouse - arrow._y;

In this example, notice that the variables in the “onEnterFrame” function are explicitly declared (using the var statement) and given a data type (e.g. Number); this means they are declared as local variables to the function, and are not available outside the function. This is good ActionScript 2.0 practice. However, in the “init” function, the variables are used, but are not declared using the var statement and are not given a data type; they are just used, which dynamically creates them in the script – an AS1 practice which isn’t good practice in AS2. The reason they are used this way is because those variables need to be available to the whole script – not just within the “init” function. However, that isn’t clear from the code – I only know that because the book explicitly says so. The intention of the code could be made explicit, and the code made pure AS2, simply by declaring those variables outside of any function. In this case that would mean adding these three lines somewhere in the code (somewhere outside of a function declaration, that is; ideally right at the top where they’re plainly visible):

var force:Number;
var vx:Number;
var vy:Number;

This happens to be an issue that I’m really picky about, perhaps more so than other people. Nevertheless, I think it’s an important one, especially since if you try to move the code to ActionScript 3, it must follow the strict AS2 rules. This means that moving into the future the reader has to do the work of figuring out how to make the examples conform to AS3 syntax, where it could have been easy to make the code work for AS2 and AS3, a better goal in my opinion than making it work for AS1 and AS2.


Although the book has a few shortcomings (at least in my opinion) which will require the reader to have a solid grounding in ActionScript 2.0 syntax in order to make the best use of it, overall I think it is a very well-written, easy to understand and thorough guide to the subject of ActionScript animation. Considering it comes from a Flash developer who is one of the most well-known for this type of work, I think it is a great book to have if you are interested in learning more about that subject.

Book details

Disclaimer: I received this book at a heavily discounted price in exchange for writing this review. While it’s impossible to remove myself from that detail completely, I have tried my best to make this an unbiased review. Want to know how to get book discounts for making reviews? Contact your local Macromedia Users’ Group.