Object-Oriented Actionscript for Flash 8 overflows with knowledge (Part 2)

If you’re looking for the ultimate book on Actionscript 2 programming, Object-Oriented Actionscript for Flash 8 should be your first choice. The book comes in at 540 pages, and holds so much knowledge that I needed to break my review into two parts. Before leaping into my thoughts on the second half, don’t forget to take a look at my previous examination.

In the second half, Peter Elst and Todd Yard take a quick look at the MX Components Framework that comes with Flash, and they use the knowledge from the first part of the book to build their own framework. Chapter 14 outlines the core classes of the MX Framework, specifically MovieClip (from the native Flash classes), UIObject, UIComponent and View. This chapter mainly offers an introduction to the idea of a framework, and you’ll later discover that the authors take some ideas from these base classes to use in their own design choices.

Elst and Yard start implementing some sound and style management classes in the next chapter. The goals for this framework aren’t quite as generic as say, Adobe’s Flex Framework, so the StyleFormat utility class that goes with StyleManager has some specific properties for things like borders, shadows, and fonts. Since these properties might not apply to every component, I don’t think I’d build it like that for my own projects. However, I think that it works well as a teaching aid to help the reader visualize the purpose of the class easier. Of course, I remember a post from Jesse Warden where he considered the need for a super-flexible framework for Flash projects with ultra-short deadlines. Ideally, such a framework would exist to solve common problems, but it would need to be enormously customizable to accomodate designers. For a project like that, simple design parameters like the ones used in the example might be a good way to speed up development.

Chapter 16 lays the groundwork for user interface components. Like Flash’s MX Framework, a UIObject class provides a common interface for use with all visual components. On the next layer, the authors implement a Block class which can be used with graphical assets. For instance, one Block might be used to skin a button component. Finally, they hope to finish up with a SimpleButton component. This chapter is one of the largest in the book and it contains a good deal of information, including integration with styles, graphics, events, states, and sounds. If you’re planning on creating reusable components, I recommend studying this section a bit to help yourself understand their methods. Even if you don’t use their base classes, the process of component development should be beneficial. It’s quite common in the Flash world to build your own components from scratch. Over the lifetime of Flash, many have developers have discovered that no magic bullet exists in this area. You have to balance flexibility, file size, performance, and more.

With a component system in place, the authors dive into animations. I found this chapter very interesting because it included many examples of using inheritance versus composition. With inheritance, a subclass takes the properties and methods from its parent class. For example, a Volkswagon “is a” Car. On the other hand, composition means that a class contains an instance of another class. A Car “has a(n)” Engine. We start out by creating a base Animator class. Two more classes, Tweener and Mover inherit from Animator. Mover, interestingly enough, uses a Tweener to handle its animation. From an OOP perspective, this design re-enforces the concept of encapsulation covered in earlier chapters, and you might not even notice that it’s happening.

In Chapter 18, “Interrelationships and Interactions Between Components”, the authors look into data binding, formatting, and validating. Unlike previous chapters, where they developed their own framework solutions from scratch, they’re now using some of the classes that come with Flash out of the box. This sort of confused me a bit. It took me a little while to realize that they had finished with the framework development, and they had moved on to the section about “Data Integration”. The section also includes browser interaction through Flash’s ExternalInterface and interaction with the server through XML and web services. It’s all very useful information that every Flash developer should know about, but I feel like this section would fit better in a more general Flash book. The rest of the book has been about learning good OOP design skills. Certainly, a good skill is knowing that you shouldn’t reinvent the wheel, but I felt like the natural progression broke during the transition to this section.

The book finally reaches its end with another case study. This time, the authors build a timesheet application. You’ll see a little UML again as the authors design the class structure. They’ll make use of the Model-View-Controller design pattern again. It’s a pretty complex little project, and you’ll want to study it, and probably recreate it in Flash to understand it well. You should pick up some good nuggets of information, and its always useful to see how others develop their projects.

I’ll admit, my love for the second half isn’t as strong as the first, but that’s a little more about the presentation style than the actual content. Whatever your skill level, I believe you’ll find some great information in Object-Oriented Actionscript for Flash 8. If you’re a Flash beginner, or you’re looking to move from the timeline into proper classes, you should have bought the book yesterday. Seriously, you won’t find a better text to help you with your transition. If you’re more advanced, you’ll find that this book is an enjoyable read that might give you some new ideas. I’ve added it to my official recommendations. As a final note, don’t let it discourage you that Actionscript 3 and Flash 9 projects might be around the corner. Focus on the object-oriented parts because it doesn’t matter what langauge you use. Good design is universal.

About Josh Tynjala

Josh Tynjala is a frontend developer, open source contributor, bowler hat enthusiast, and karaoke addict. You might be familiar with his project, Feathers UI, an open source user interface library for Starling Framework that is included in the Adobe Gaming SDK.

Discussion

  1. Pingback: Object-Oriented Actionscript for Flash 8 overflows with knowledge » Zeus Labs

  2. conspirisi

    great book and good discussion of AS 2.0 components, problem is how much is relevant now AS 3.0 is the flavour of the day?

  3. Tink

    Most of the content in this book is still relevant for AS 3.0. Yes the syntax has changed, but the concepts and patterns still apply.

  4. Josh Tynjala

    Well, Flash 9 and AS3 just came out a couple months ago. It will be some time before content producers feel that it has a large enough install base. I know that many still target Flash 7, so expect Flash 8 to stick around for a while.

    Also, as I said at the end of my review, “design is universal”. Good OOP skills in AS2 transfer to AS3. Moreover, good OOP skills in Flash can be beneficial to any other programming language you use.

  5. conspirisi

    I guess you right. I feel a bit of a lightweight actionscripter but I’m taking a break from ActionScript, in this AS 2.0 – AS 3.0 transitional phase, in order to learn php mysql.

  6. conspirisi

    Whilst i’m on the subject of OOA for Flash 8. I was a little dismayed/amused when I reached chapter 17 by which time I’d learned the merits and joys of UML diagrams and was then told…..

    “…Making a break from the process of previous chapters, we’ll dive right into the code without spending to much time in the planning stages. Sometimes, especially when creating code for animation and effects, a lot of experimentation happens to get what it is wanted, and creating too rigid a box to work in makes it difficult to break out of. After the stucture and discipline applied in the previous chapters (and now your comfortable with when and how to create UML diagrams to help with planning) let’s give ourselves a little freedom to have some fun in this chapter.” pg 334

    I thought all of this UML palava was meant to help you experiment? Anyway don’t get me wrong it is a great book, but I can’t help but think developing a OOA app in Flash 8 could still be a very frustrating experiance for the average developer.

  7. Josh Tynjala

    Sometimes, it’s easier to visualize how something should work by simply diving in and trying to implement it. Classes related to design, like those animation classes, might work better with parameters that you haven’t even considered yet. As a result, even if you diagram everything in UML at the beginning, you’re classes might evolve in the same way as if you simply started coding from scratch.

    I’m not a big fan of UML. I think it’s great for situations when I’m having trouble figuring out the best way to structure my classes, but I don’t use it very often. Some OOP purists probably disagree with that, but I don’t mind.

  8. Pingback: Object-Oriented Actionscript for Flash 8 overflows with knowledge - Zeus Labs