PREFACE

When deciding if the book in your hands will be a good resource for your library, it might help you to know why we, the authors, wrote this particular book. We are both developers who use Flash extensively in our everyday work, but we are also teachers. Collectively, we have taught thousands of students at multiple universities, training facilities, and conferences, and yet we share one significant common experience. We were consistently told that no feature-rich ActionScript book satisfied this beginner audience.

At first we were surprised at how truly overwhelming this sentiment was, but then we realized that we didn’t have enough information to form an opinion. We didn’t use beginner resources in our work and had only our own curriculum to go on. So, we started to research how we could fill this void and provide a book to our students that would really help them beyond the classroom. We talked with a lot of students, user groups, and instructors and began to sketch out a book that we thought would put what we learned into practice.

When ActionScript 3.0 was released, the interested audience grew dramatically. Reactions ranged from excitement to uncertainty to fear, as the ActionScript 3.0 learning curve became apparent. Talk of the Flash Platform splintering into Flex (“developer”) and Flash (“designer”) camps left many designers and beginner programmers more uncertain than ever about their futures. When Flash CS3 Professional was released, the need for a guiding resource didn’t dissipate (and, in many cases, increased), and we knew it was time to develop the book you hold in your hands.

We hope this book will help Flash users of all kinds—from curious to intimidated, from eager to experienced—embrace the power and performance of ActionScript 3.0. We hope these pages will ease the transition from whatever prior version, if any, of ActionScript might have been in use, to the biggest architectural change to the language since its inception.

Who This Book Is For

This book is aimed at Flash designers and developers coming to ActionScript 3.0 for the first time, as well as beginner programmers looking to brush up on their ActionScript 3.0 knowledge. Although we feel this volume covers the basics fairly well, both a familiarity with the Flash interface and a small amount of scripting experience is assumed.

We believe we’ve explained the material herein clearly and concisely enough for any reader to get started, so even if you are new to programming, we welcome you! However, if you have a few moments, we recommend that you skim Chapter 2 to see if you think we’ve provided enough core programming fundamentals to fill any gaps in your knowledge base. Throughout this book we cover relevant syntax with extensive comments, but the first two chapters serve as a foundation upon which the rest of the chapters are built.

Similarly, if you are a relatively experienced ActionScript 2.0 programmer, you may wish to glance at a few chapters of interest before deciding whether or not this book is for you. We highlight ActionScript 2.0-to-ActionScript 3.0 migration issues, but want you to be happy with the tone and straightforward approach we’ve adopted before you decide to rely on this book. We endeavor to teach the basic principles behind each chapter topic in a form, chapter number, and page count that is easily digested. In any case, take a moment to read through the next two sections to make sure this is the right book for you.

How This Book Is Organized

Unlike any other book on ActionScript 3.0 that we’ve seen, this book does not rely extensively on object-oriented programming (OOP) principles. If you are unfamiliar with this term, don’t worry. You have the correct book in your hands, and you’ll learn more with each successive chapter.

We demonstrate key chapter concepts using focused syntax that is executable within the timeline, and gradually introduce OOP concepts along the way. The first five chapters—including coverage of the new ActionScript 3.0 event model and means of displaying content (the display list)—do not introduce more than a modicum of content that is class- or OOP-related. Starting in Chapter 6, we provide increased object-oriented coverage, beginning with an OOP primer, and continuing for the remaining nine chapters with select class- or OOP-based applied examples.

If you’re interested in immersing yourself in OOP examples from the outset, all of the main chapter examples are also available in class form in the downloadable source code. This not only provides a jumpstart for those with some OOP experience, but it also serves as a self-guided learning opportunity if you find yourself a bit ahead of the learning curve. Best of all, Flash CS3 Professional’s new Document Class feature allows you to start using classes more quickly than ever before, allowing a class to serve as a kind of stand-in for the main timeline of any .fla file. All you have to do to use it is enter the name of the class in the Flash Property Inspector. (If you can’t wait to learn more, jump to the section "The Document Class" in Chapter 1.)

Finally, we’ve designed an expanded project to go hand in hand with this book. Beginning with Chapter 7, the first chapter following our OOP primer, the downloadable source code features a class package for every chapter. The classes include handy utility methods and properties that will be used in the supplemental project. When you feel comfortable with the syntax of ActionScript 3.0, and the basic principles of object-oriented programming, you can reinforce what you’ve learned by building the project. The files are available from the book’s companion web site, which we’ll talk about in just a moment.

What Is—and Isn’t—In This Book

We’ve tried to design a book that covers as many ActionScript essentials as we could include, given its size and scope.

What’s In

Part I

Part I begins with Chapter 1, discussing ActionScript 1.0, 2.0, and 3.0, and how the different versions are used in the Flash CS3 Professional application and Flash Player. It concludes with Chapter 2 looking at the building blocks that are ActionScript’s language-neutral core fundamentals.

Part II

Chapter 3 leads off Part II, the largest section of the book, with explanations of the basic vocabulary of ActionScript: properties, methods, and events (including ActionScript 3.0’s significantly different event model). Chapter 4 focuses on displaying content dynamically, Chapter 5 covers timeline control, and Chapter 6 introduces OOP. Chapter 7 discusses animating objects using ActionScript, and Chapter 8 and Chapter 9 explain drawing with code.

Part III

Chapter 10 is the only chapter in Part III and focuses on text formatting, HTML support, and the use of cascading style sheets.

Part IV

Chapter 11 opens Part IV with a discussion about sound. In addition to manipulating internal and external sounds, it touches on parsing of ID3 metadata and culminates with a sound visualization exercise, drawing a sound’s waveform during live playback. Chapter 12 wraps up Part IV by demonstrating how to play video both with and without components, as well as how to subtitle your videos for accessibility and multilingual support.

Part V

Part V focuses on loading assets into Flash and sending data out to a server or another client. Chapter 13 covers loading SWF files, images, and URL-encoded data, as well as communicating between ActionScript 3.0 and ActionScript 1.0/2.0 loaded SWFs, and a brief discussion of security issues. Chapter 14 covers XML and the new standard for working with XML that makes the task as easy as working with other ActionScript objects, methods, and properties.

Part VI

We wrap up the book with Part VI. Chapter 15 takes a short look at programming methodologies, object-oriented design patterns, and resources for further learning.

What’s Not

This book focuses on ActionScript 3.0, which applies to most segments of the Flash platform, but it is presented within a Flash CS3 Professional context. As such, it does not include coverage of Flex, AIR, Flash Media Server, or other evolving Flash platform technologies.

Further, while it does include coverage of object-oriented programming techniques, it does not address this material in great depth. For more information about this point, please see the previous section, "How This Book Is Organized.”

As an entry-level text, this book has understandable constraints that limit the extent of coverage we can offer. Browsing through the Table of Contents should give you a pretty good idea of the topics we’ll be featuring and, in some cases, the depth in which we will cover the material. However, there are a few notable areas of ActionScript that are not discussed at all due to their intermediate or advanced nature. These include database connectivity, regular expressions, programming for mobile devices, Web services, remoting, and creating your own components.

We don’t claim that this is a reference book. If you’re an experienced ActionScript programmer looking for a quick start with version 3.0 of the language, we recommend that you read the ActionScript 3.0 Cookbook, by Joey Lott, Keith Peters, and Darron Schall (O’Reilly). If you are looking for a comprehensive reference book, we recommend trying Essential ActionScript 3.0 by Colin Moock (O’Reilly). Our book may serve as a useful companion to one of these titles, particularly if you are not an advanced user, but it is not a substitute for either.

Companion Web Site

All the exercises included in this book are available for download from the book’s companion web site, http://www.LearningActionScript3.com. Supplemental materials are also available, including additional exercises, self quizzes, extended examples, ongoing learning suggestions, an expanded resource list, reader comments, errata, and more. Various community resources will be added to the site, such as a forum in which we will participate. Both authors can be reached directly through this web site.

Typographical Conventions Used In This Book

The following typographical conventions are used in this book:

Plain Text

Indicates menu titles, menu options, menu buttons, and keyboard modifiers (such as Alt and Command).

Italic

Indicates new terms, URLs, email addresses, filenames, file extensions, pathnames, and directories.

Constant width

Indicates ActionScript code, text output from executing scripts, XML tags, HTML tags, and the contents of files.

Constant width bold

Shows commands or other text that should be typed literally.

Constant width italic

Shows text that should be replaced with user-supplied values.

Note

A note gives additional information, such as resources or a more detailed explanation.

Warning

This box indicates a warning or caution.

Using Code Examples

This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: Learning ActionScript 3.0 by Rich Shupe and Zevan Rosser. Copyright 2008 O’Reilly Media, Inc., 978-0596527877.

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .

We’d Like to Hear from You

Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
(800) 998-9938 (in the United States or Canada)
(707) 829-0515 (international or local)
(707) 829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at:

http://www.oreilly.com/catalog/9780596527877

To comment or ask technical questions about this book, send email to:

For more information about our books, conferences, Resource Centers, and the O’Reilly Network, see our web site at:

http://www.oreilly.com

Acknowledgments

Rich and Zevan would like to give special thanks to their peerless O’Reilly team: Robyn Thomas, Steve Weiss, Michele Filshie, Matthew Roberts, Jill Steinberg, Joy Dean Lee, Ron Bilodeau, Phil Dangler, Linda Seifert, Mark Paglietti, Karen Montgomery, and Laurie Petrycki. This team of wonderful people bent over so far backwards for this book, we heard spines cracking all over the country. We couldn’t have been in better hands. Extra special thanks go to Robyn for endless patience and support.

Zevan would like to thank: Rich Shupe, The School of Visual Arts, Jesse Reznick and the creative team at SOM, Ann Oren, all of his students, and his family.

Rich would like to thank: Zevan Rosser, Jodi Rotondo, Sally Shupe, Steven Mattson Hayhurst, Thomas Yeh, Aaron Crouch, Anita Ramroop, and his family for helping make this book possible.

Rich would also like to show his appreciation for:

  • Bruce Wands, Joe Dellinger, Russet Lederman, Mike Barron, Jaryd Lowder, Diane Field, The School of Visual Arts, and all his students.

  • Lynda Weinmann, Bruce Heavin, Toby Malina, Christoph Weise, Kevin Skoglund, and everyone at FlashForward.

  • Terry O’Donnell, Russell Jones, and DevX.com; Karen Schneider; Paul Kent, Kristen Margulis, and IDG; John Davey and Flash on the Beach; Dave Schroeder and Flashbelt; Susan Horowitz, William Morrison, and University of Hawaii’s Outreach program.

  • Mike Downey, Mike Chambers, Richard Galvan, Nivesh Rajbhandari, Mally Gardiner, Jeff Kamerer, Michael Ninness, John Nack, Pete Falco, and Adobe.

  • Aral Balkan, Pete Barr-Watson, Brendan Dawes, Chris Georgenes, Mario Klingemann, Seb Lee-Delisle, André Michelle, Erik Natzke, Keith Peters, Tim Saguinsin, Grant Skinner, Craig Swann, Jared Tarbell, Carlos Ulloa, and no doubt others that I’m forgetting for support and/or inspiration.

  • Welcome Mina! This book is for Sally and ?....

Get Learning ActionScript 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.