Developer

Object-oriented Flash is the real deal

According to a recent book by Bill Drol, object-oriented Flash MX development is not an oxymoron. Drol walks you through creating reusable Flash services employing the core tenets of object-oriented programming.


If you consider yourself a "real" developer, you may not take Flash seriously and dismiss it as a “fluff” development tool/environment. Frankly, I agreed with you until I read Object-Oriented Macromedia Flash MX by Bill Drol. In this book, Drol does an excellent job of explaining object-oriented techniques, using Flash MX ActionScript to illustrate his points. Even though Flash may have a less-than-stellar reputation in the developer community when compared to Java or C#, Drol makes a strong case for taking Flash seriously.

Object-Oriented Macromedia Flash MX

By William Drol
Apress
June 2002
504 pages
ISBN: 1-59059-014-7
Cover price: $44.95



A book for all levels of experiences—sort of
This book is best suited for HTML/DHTML developers who want to move into object-oriented (OO) development or for Flash designers looking to dive deeper into ActionScript. If you have a strong Java or other OO language background and you’re trying to learn ActionScript, then you may be bored with the first 10 chapters. However, inexperienced programmers will greatly benefit from Drol’s explanation of the three basic tenets of OO development—encapsulation, inheritance, and polymorphism.

What you can expect
While not intended to be a reference book, the author does offer an overview of ActionScript and some of the syntax variances that can drive a veteran coder batty, especially one who is keen on good form. One of the most helpful parts of the books to me came at the end of chapter four, where Drol discusses ActionScript trouble spots, such as case-sensitivity inconsistency. Here’s an example that illustrates why ActionScript hasn’t yet made it to the forefront of development tools. ActionScript doesn't distinguish between:
var myBankAccount = 8635;

and
var mybankaccount = 8635;

Drol takes great pains to reinforce the importance of coding conventions for several reasons, namely readability and ease of maintenance. He stresses the need for consistent use of capital letters, because versions of Flash may enforce capitalization more strictly than the current release. He even dedicates a short chapter on how to plan for encapsulation and inheritance, including the requisite diagrams.

One other trouble spot worth noting is that ActionScript doesn't support public and private classes, so the burden of keeping this straight falls on your shoulders. Again, Drol offers some techniques on writing reusable classes in ActionScript, and he preaches the gospel of code organization.

XML in a Flash
The last five chapters dive headfirst into XML syntax rules, such as case sensitivity and the order of closing tags. Drol introduces XML and then covers the specifics of Flash’s built-in XML classes, so you can load and read XML data. I give Drol kudos for attempting to tackle recursion, the process by which a function calls itself. If you don’t have a strong programming background, you may have to read this section a couple of times to get the hang of it (at least I did when I first encountered it in C++). Drol does a great job with his straightforward explanation of how you can employ recursion to visit every node in any XML document.

Drol warns that you shouldn’t depend on Flash to validate your XML documents because Flash interprets them in a looser fashion. For example, Flash lets you start a tag with a number, which is an XML no-no. After working through these concepts, Drol walks you through the process of creating a dynamic framework for creating content. The book’s primary example is how to build a menu service. The author wraps up by showing you how to build a dynamic menu template, which is the icing on the cake when it comes to reusing services in Flash.

Drawbacks of the book
As I previously mentioned, one of the book’s biggest drawbacks is that the first 10 chapters or so may be too elementary for experienced developers. However, you will find the chapters on XML to be solid and helpful when you plan for a reusable Flash service architecture.

Also, I was hoping for more enterprise-related examples. Instead of using bouncing balls to illustrate his point, perhaps Drol could have used something that relates to developing a Flash front end for Web-based training.

Overall, I think that Object-Oriented Macromedia Flash MX would make a nice bookshelf addition for any self-respecting Flash developer.

Have a favorite book that you want to review?
If you have a great or not-so-great book to review, please contact the editors or post a comment below.

 

Editor's Picks

Free Newsletters, In your Inbox