Object oriented programming: Action Script

•July 4, 2008 • Leave a Comment

I imagine some readers might have no idea what a class or the term “object oriented” means, while others have been using classes in ActionScript (or other languages) for years. So as to not lose anyone, I’m going to try to cover all the basics. AS 2 OOP experts might want to at least skim this section, too, as there are quite a few changes in the way things work in AS 3. If you think you do not have any familiarity with classes, you may be wrong. If you’ve written any code in Flash, chances are you used several classes. A class simply refers to a type of object. MovieClip is a class referring to—you guessed it—movie clips. Text fields, movie clips, buttons, strings, and numbers all have classes.

A class basically has two things associated with it: properties (data or information) and behaviors (actions, or things it can do). Properties are essentially variables that hold information relating to the class, and behaviors are just functions, though when a function is part of a class, we usually refer to it as a method.


Starting your work with Flash

•July 4, 2008 • Leave a Comment

The first thing you see when you launch Flash is the Start page shown in Figure 1-1. This interface, common to all of the Adobe CS3 applications, is divided into three areas. The area on the left side shows you a list of documents you have previously opened. Click one of them, and that document, provided it hasn’t been moved to another location on your computer, will open. The Open link at the bottom of the list lets you navigate to a document that isn’t on the list.

The menu
The menu

The middle area of the page is where you can choose to create a variety of new Flash documents. Your choices include a blank Flash document, a project aimed at a cell phone or PDA (a mobile document), a series of code-based documents, and a Flash project. The major change in this panel is the ability to select a new document based upon which version of ActionScript will be used in the document. Flash Professional CS3 marks the latest version of the Flash programming language named ActionScript. The previous version of this language, used in Flash MX 2004 and Flash 8, was ActionScript 2.0. The right area of the page is reserved for a variety of templates you can use. Clicking one of the folders opens the New from Template dialog box, as shown in Figure 1-2. The Extend area at the bottom of this column contains a link to the Flash Exchange. This is a hyperlink that takes you to a page on the Adobe site where you can download a variety of tools and projects that are available for free or a nominal cost. Let’s open a new document. Simply click Flash File (ActionScript 3.0) in the Create New area of the Start page to open the Flash interface.

Already made themes

Already made themes

The interface that opens is the feature-rich authoring environment that is the heart and soul of Flash. If you are an existing Flash user, the first thing that will catch your attention is that the interface looks somewhat different from previous versions of the application. In next posts we will try to focus more on Flash Animation and Flash Components.

The continuation: Flash

•July 4, 2008 • Leave a Comment

I can remember the day as clear is if it were just yesterday. I was walking by my boss’ office late one winter afternoon at the college where I teach, and he called me into his office. Sitting on his desk was a thin white box with some sort of weird swirl on it. He slid the box across to me and asked, “You know anything about Flash?” To be honest, as a Director user, what I knew was filtered through the eyes of a Director guy, which meant I didn’t know much and what I did know convinced me it was a wind-up toy compared to Director. I replied, “A bit.” The boss leaned back in his chair and said, “Well learn a lot more because you are teaching it in four weeks.” This was the start of one of the longest, strangest, and most exhilarating trips I have ever been on. The version was Flash 3, and I have been using and teaching Flash ever since. In many respects, Flash CS3 completes the process started by Macromedia, now Adobe, with the release of Flash 8. That release was a “designer” release, meaning there were lots of goodies for the creatives and a few for the coders. This iteration of the application is the “developer” release. The coders are dancing in the streets, and the creatives are wondering what the hell happened.

In many respects, this release of the application marks the absorption of Flash into the Adobe product line, and Adobe didn’t just toss it on the pile. As you will discover, there are some seriously cool new features that allow Flash users to take advantage of new work flows among all of the applications in the Adobe lineup including Photoshop CS3, Illustrator CS3, Fireworks CS3, Dreamweaver CS3, and even After Effects CS3 and Soundbooth CS3. The big news, of course, is the introduction of ActionScript 3.0. This revision of the Flash scripting language will initially, in the immortal words of Ed Grimley, “Drive you mental!” The key word is “initially,” because once you get used to it, you will discover everything you know about ActionScript still applies . . . just a bit differently. When Dave and I started mapping out this book, we decided to go with ActionScript 3.0 for every line of code in the book. In this way, you can learn the fundamentals and use them as a jumping-off point to further explore the power of this language. This book is also a bit different from any Flash book you may have read or considered purchasing. From the very start of the process, Dave and I put ourselves in your shoes and asked a simple question: “What do you need to know and why?” This question led us into territory that we didn’t quite expect. As we were grappling with that question early in the process, we kept bothering our network of Flash friends to be sure we were on the right track. At some point, both of us simultaneously came to the conclusion, “Why not just let them explain it in their own words?” This is why, as you journey through this book, you will encounter various experts in the field telling you why they do things and offering you insights into what they have learned. The odd thing is, at some point in their careers, they were no different from you.

One other aspect of this book that we feel is important is we had a lot of fun developing the examples and exercises in the book. The fun aspect is important because if learning is fun, what you learn will be retained. Anybody can show you how to apply a Glow filter to a line on the Flash stage. It is more effective when you do exactly the same thing to a guy wearing a Tron suit. Anybody can dryly explain 9-slice scaling, but it becomes less techie when you apply it to a guy dressed as Peter Pan. Nested movieclips are a “yawner” at best, but when they are related to a Hostess Twinkie, the concept becomes understandable. Shared libraries are an important subject. Instead of filling a library with circles and text, the concept becomes relevant when the library is populated with “Bunny Bits.”

As you may have guessed, we continue to exhibit a sense of joy and wonder with Flash, and we hope a little bit of our enthusiasm rubs off on you as well. For thoes whi are really interested in Flash Animation, I’d recomend checiking google for useful tutorials.

The first entry: Flash

•July 4, 2008 • Leave a Comment

Like a lot of kids, I was entranced by animation. My childhood was littered with flipbooks, doodles, and at least one zoetrope I built from a kit. I even had an electronic toy called the Etch-a-Sketch Animator that let you create 12 black-and-white “pictures” on a 30540-pixel screen and make them play back in sequence. This created possibly the worst animation ever, but to a 10-year-old it was the coolest thing!

This love for animation was lost for a few years, as I got deeper and deeper into computers. As I moved through high school and kept learning new operating systems and programming languages, I was starting to realize that one day working/playing with computers could be my career.

Then, in my sophomore year of college, I was introduced to Flash. All of the books I had read about Disney, Warner Brothers, and Hanna-Barbera came flooding back to me. With recklessabandon I learned everything I could about Flash—and was done after about a week. Flash wasn’t exactly complicated in those days, and ActionScript didn’t consist of much more than stop and play.

The good news was that I was in a perfect place for keeping pace with Flash as it grew—my programming background along with my love for animation let me keep on top of every new version of Flash as it was released. I was in the enviable position of being able to just ride the wave from version to version.

During that time, I spoke at and attended a lot of Flash conferences, where I was lucky enough to meet both Tom Green and David Stiller. If you’re ever in a room with Tom, you’ll know—the raucous laughter is your first clue. Tom has a real exuberance for learning, teaching, and life in general that is all too rare in this world. He is constantly striving to learn more and discover new ways to convey that knowledge to his students. As for David, he is from the true old school—a modern-day Renaissance man. He struck up a conversation with me about obscure board games a few years ago. The conversation wound its way through quantum mechanics, the proper brewing of Turkish coffee, and toy building, and technically is still going on today. I am proud to be able to call on him as a contractor for my company and even more proud to call him a friend. Ever since Flash Animation and Flash Components have become my main goal.