![]()
Book Details:
- ActionScript 3.0 Cookbook
- Joey Lott, Darron Schall, & Keith Peters
- O’Reilly Media, Inc.
- List: $39.99 Amazon.com: $26.39
- ISBN: 0-596-52695-4
- 556 Pages
By now, most Flash developers know that ActionScript 3.0 is a huge improvement over ActionScript 1.0 & 2.0. These improvements come in the form of faster performance, enhanced features, and the general awesomeness that comes with using the AVM 2 in Flash Player 9.
However, one of the biggest hurdles in using AS 3.0 is learning it. There are many similarities between AS 2.0 & AS 3.0, but for all the similarities, there are plenty of differences. If you’re an experienced Flash developer, fluent in AS 2.0, you’ll be able to pick up AS 3.0 fairly easily. The biggest trick, (at least for me) is learning the new way to do things in AS 3.0 that have become second nature in AS 2.0. And that’s where the ActionScript 3.0 Cookbook comes in.
First, this book is not for ActionScript beginners. It is written for ActionScripters who already have an idea of what they’re doing. The first chapter covers some ActionScript 3.0 basics, and will help you get up to speed with AS 3.0, showing how to setup things that you would be familiar with in AS 2.0, such as listening for mouse & keyboard events, using onEnterFrame events, and using the new Timer class as opposed to setInterval() or setTimer(). This first chapter also covers setting up ActionScript projects using Flex Builder 2.
(The book does assume that you’re using Flex Builder 2 when teaching you how to setup your projects, but it’s not required to use any of the code in this book. It would have been nice if they had also mentioned using the command-line compilers that are part of the free Flex SDK.)
In my opinion, where this book really shines is in the ability to look up something that you know how to do in AS 2.0, but are a little lost in AS 3.0. Such as loading an external image to use with BitmapData, or loading and parsing XML files. I could spend time with documentation and try to sort out what classes to use for something, but this book helps you by providing examples of what classes would be needed to perform a function and how they work together. It will show you the basics, which you can then build upon by going back to the documentation and seeing what else you can do.
The book lives up to it’s designation as a ‘cookbook’. Each entry is listed as a sort of recipe. You determine what you want to do, such as finding points along the edge of a circle, then look it up, and find the associated ‘recipe’ that explains the basics behind what you’re going to do, and then provides a code example. While there are several entries that could easily belong in the actual documentation for AS 3.0, I didn’t mind them so much because the entries in this book went into a little more detail than the official documentation does. I also found the Table of Contents to be more useful in finding things than I did the index of the book. It was pretty easy to skim over the contents to find something that sounded like what I was looking for.
There are entries for useful things like image editing (contrast, brightness, inverting an image, etc.), and string manipulation, including a mini tutorial on using regular expressions. As well several entries on using scripted animation, including acceleration, gravity, tweening, & simulating springs.
I did have a few issues with the book however. The biggest one being the ‘filler’ content. There are a few entries that I feel were included more to pad the page count or to increase the total amount of ‘recipes’. In a book that is not designed for ActionScript n00bs, I don’t think that it’s necessary to devote 2 ½ pages to using basic operators such as ‘+’ and ‘-’. (1.7, Using Mathematical Operators). This is something that should be taught within the first ten pages of a beginning ActionScript book. There are seven pages to provide ‘recipes’ on using conditionals such as if/else, and switch, and doing comparisons with ‘==’ and ‘< '.
Another gripe I had was the use of a set of custom classes to serve as solutions to some of the problems. The book’s website provides a series of custom classes that can be used for various things. There are a series of utility classes, such as ArrayUtilities, StringUtilities, and NumberUtilities, that provide functions like shuffling the elements of an array, or returning a random number from a range specified. There is also a class provided to simulate a deck of cards.
I don’t have a problem with the fact that these classes are provided, in fact, some of them will be pretty useful in the future. The issue I had was that these classes were sometimes used as the solution to one of the problems provided. Instead of showing the code of how to generate a random number between a specific range, to simulate rolling dice or a coin toss for example, the solution provided is to simply use the NumberUtilites.random() method. The classes provided are cleanly written, so you’ll be able to look at the code and see how the various methods accomplish their tasks, but they’re not commented, so you’ll need to figure a few things out yourself if you want to see what the code actually does to accomplish it’s task. It would still have been nice though if some of the solutions provided by the classes were explained in the text instead of the class being presented as the way things get done.
Though, even with these problems, I still felt like the good outweighed the bad in this book, and it’s a welcome addition to my geek library. It does have some very useful chunks of code, and is a handy quick reference for a lot of problems. Even if you’re working on an AS 2.0 project, many of these code snippets could easily be ported to AS 2.0, provided that they’re not using anything AS 3.0 specific.
Final Score: 4/5
Leave a Reply