foundation flash cs5 for designers - springer978-1-4302-2995-7/1.pdf · to sarah and rory mcgrath...

20
Foundation Flash CS5 for Designers Tom Green and Tiago Dias DESIGNER TO DESIGNERTM an Apress» company

Upload: lynguyet

Post on 28-Jul-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

Foundation Flash CS5 for Designers

Tom Green and Tiago Dias

DESIGNER TO DESIGNERTM

an Apress» company

Foundation Flash CS5 for Designers Copyright © 2010 by Tom Green and Tiago Dias

All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system,

without the prior written permission of the copyright owner and the publisher.

ISBN-13 (pbk): 978-1-4302-2994-0

ISBN-13 (electronic): 978-1-4302-2995-7

Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1

Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logos, or image we use the names, logos, or images only in an

editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.

The use in this publication of trade names, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.

Distributed to the book trade worldwide by Springer Science+Business Media LLC., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-

sbm.com, or visit www.springeronline.com.

For information on translations, please e-mail [email protected] or visit www.apress.com.

Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–

eBook Licensing web page at www.apress.com/info/bulksales.

The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person

or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work.

The source code for this book is freely available to readers at www.friendsofed.com in the Downloads section.

CreditsPresident and Publisher:

Paul Manning

Lead Editor:Ben Renow-Clarke

Technical Reviewers:Cheridan Kerr, Kristian Besley

Editorial Board: Clay Andres, Steve Anglin, Mark Beckner,

Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie,

Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke,

Dominic Shakeshaft, Matt Wade, Tom Welsh

Coordinating Editor:Mary Tobin

Copy Editor:Kim Wimpsett

Compositor:Lynn LHeureux

Indexer:Kevin Broccoli

Artist:April Milne

Cover Designer:Anna Ishchenko

To Sarah and Rory McGrath in Berne, Switzerland. May your marriage be one of peace, love, and joy.

—Tom Green

iv

Contents at a Glance

About the Authors................................................................................................... xiv About the Technical Reviewers .............................................................................. xv Acknowledgments .................................................................................................. xvi Preface................................................................................................................... xviii

Chapter 1: Learning the Flash CS5 Professional Interface ..................................... 1 Chapter 2: Graphics in Flash CS5........................................................................... 67 Chapter 3: Symbols and Libraries ........................................................................ 151 Chapter 4: ActionScript Basics............................................................................. 213 Chapter 5: Audio in Flash CS5 .............................................................................. 279 Chapter 6: Text ....................................................................................................... 315 Chapter 7: Animation, Part 1 ................................................................................. 361 Chapter 8: Animation, Part 2 ................................................................................. 427 Chapter 9: Flash Has a Third Dimension.............................................................. 495 Chapter 10: Video................................................................................................... 527 Chapter 11: Building Interfaces with the UI Components ................................... 601 Chapter 12: XML (Dynamic Data) .......................................................................... 643 Chapter 13: CSS..................................................................................................... 669 Chapter 14: Building Stuff ..................................................................................... 695 Chapter 15: Optimizing and Publishing Flash Movies......................................... 757

Index ....................................................................................................................... 809

v

Contents

About the Authors................................................................................................... xiv About the Technical Reviewers .............................................................................. xv Acknowledgments .................................................................................................. xvi Preface................................................................................................................... xviii

Chapter 1: Learning the Flash CS5 Professional Interface ..................................... 1 Getting started ............................................................................................................................. 2 Creating a new Flash document................................................................................................. 5Managing your workspace .......................................................................................................... 6 Setting document preferences and properties .......................................................................... 8

Document preferences ......................................................................................................... 9 Document settings .............................................................................................................. 10Zooming the stage .............................................................................................................. 11

Exploring the panels in the Flash interface.............................................................................. 14 The timeline......................................................................................................................... 14 The Properties panel .......................................................................................................... 23 The Tools panel .................................................................................................................. 29 The Library panel ................................................................................................................ 31

Using layers ............................................................................................................................... 32 Layer properties .................................................................................................................. 33 Creating layers .................................................................................................................... 34 Adding content to layers..................................................................................................... 36Showing/hiding and locking layers .................................................................................... 38 Grouping layers................................................................................................................... 40 Where to get help................................................................................................................ 40

Your turn: building a Flash movie ............................................................................................. 42Nesting movie clips............................................................................................................. 45 Drawing the fly .................................................................................................................... 47 Creating the illusion of depth with Flash ........................................................................... 48 Creating an animated fly .................................................................................................... 55 Adding audio ....................................................................................................................... 59 Testing and saving Flash files............................................................................................ 61

You have learned....................................................................................................................... 65

vi

Chapter 2: Graphics in Flash CS5........................................................................... 67 The Tools panel ......................................................................................................................... 70

The Selection and Subselection tools ............................................................................... 72 The Free Transform tool..................................................................................................... 75 The Gradient Transform tool .............................................................................................. 77 Object Drawing mode ......................................................................................................... 80

Drawing in Flash CS5................................................................................................................ 83 The Pencil tool .................................................................................................................... 83 The Brush tool..................................................................................................................... 85 The Deco tool ...................................................................................................................... 88 The Spray Brush tool .......................................................................................................... 98The Eraser tool.................................................................................................................. 101 The Pen tool ...................................................................................................................... 102

Your turn: let’s have a campfire.............................................................................................. 104Drawing the tree trunk ...................................................................................................... 104Drawing the pine tree ....................................................................................................... 106Adding pine needles .........................................................................................................107Build the campfire movie ..................................................................................................108

Working with color in Flash ..................................................................................................... 110 The Color palette and the Color Picker ........................................................................... 112Creating persistent custom colors ...................................................................................115The kuler Color Picker ...................................................................................................... 117Your turn: playing with color.............................................................................................119

Using bitmap images in Flash.................................................................................................123Working with bitmaps in Flash .........................................................................................125Your turn: tracing bitmaps in Flash..................................................................................127JPEG files and Flash ........................................................................................................ 131Using GIF files in Flash CS5............................................................................................134Importing Fireworks CS5 documents into Flash CS5 .................................................... 137Importing Illustrator CS5 documents into Flash CS5 ..................................................... 140Importing Photoshop CS5 documents into Flash CS5................................................... 146

You have learned..................................................................................................................... 149

Chapter 3: Symbols and Libraries ........................................................................ 151 Symbol essentials.................................................................................................................... 152Symbol types............................................................................................................................ 155

Graphic symbols ...............................................................................................................155Button symbols.................................................................................................................. 156 Movie clip symbols............................................................................................................ 158Editing symbols ................................................................................................................. 159

vii

9-slice scaling .......................................................................................................................... 160How 9-slice scaling works ................................................................................................161Your turn: frames for an olive seller.................................................................................163The 9-slice “gotchas” ........................................................................................................ 166

Sharing symbols ...................................................................................................................... 169Sharing libraries ................................................................................................................ 171

Filters and blend modes.......................................................................................................... 174 Applying filters ................................................................................................................... 174Applying a Drop Shadow filter..........................................................................................175Adding perspective ........................................................................................................... 177Playing with blends ........................................................................................................... 180

Managing content on the stage ..............................................................................................184Aligning objects on the stage ...........................................................................................186Stacking order and using the Align panel ....................................................................... 189

Masks and masking.................................................................................................................194A simple mask................................................................................................................... 194 Using text as a mask ........................................................................................................ 201

Your turn: a sunny day on Catalina Island............................................................................. 205Adding the clouds .............................................................................................................206Getting the clouds in motion.............................................................................................208

What you’ve learned................................................................................................................ 211

Chapter 4: ActionScript Basics............................................................................. 213 The power of ActionScript ....................................................................................................... 214

Actions panel components ...............................................................................................216The Actions panel vs. the Behaviors panel.....................................................................219

Everything is an object ............................................................................................................ 220Classes .............................................................................................................................. 221Properties ..........................................................................................................................222

Setting properties via ActionScript ......................................................................................... 225Methods ............................................................................................................................. 226Events................................................................................................................................ 229

Coding fundamentals .............................................................................................................. 233 Syntax................................................................................................................................ 233Capitalization matters ....................................................................................................... 233Semicolons mark the end of a line ..................................................................................234Commenting code............................................................................................................. 235Dot notation ....................................................................................................................... 237Scope................................................................................................................................. 239Variables............................................................................................................................ 240

viii

Data types ......................................................................................................................... 241Operators........................................................................................................................... 244Conditional statements .....................................................................................................247Class files and the document class .................................................................................251Syntax checking ................................................................................................................253

How to read the ActionScript 3.0 Language and Components Reference.......................... 257Getting help ....................................................................................................................... 258Search tactics.................................................................................................................... 259

Using ActionScript ................................................................................................................... 260Your turn: pause and loop with ActionScript..........................................................................261

Pausing a timeline.............................................................................................................261Looping the Timeline ........................................................................................................265Using movie clips to control the timeline .........................................................................266Using Code Snippets........................................................................................................266

What you’ve learned................................................................................................................ 276

Chapter 5: Audio in Flash CS5 .............................................................................. 279 Flash and the audio formats ................................................................................................... 280

Bit depth and sample rates ..............................................................................................281Flash and MP3 ..................................................................................................................283

Adding audio to Flash.............................................................................................................. 284Importing an audio file ...................................................................................................... 284Setting sound properties ..................................................................................................285

Using audio in Flash ................................................................................................................ 288Choosing a sound type: event or streaming ...................................................................288Removing an audio file from the timeline ........................................................................ 291Getting loopy ..................................................................................................................... 291 Adjusting volume and pan ................................................................................................293

Your turn: adding sound to a button .......................................................................................296Controlling audio with ActionScript 3.0 ..................................................................................298

Playing a sound from the Library .....................................................................................298Using a button to play a sound ........................................................................................300Playing a sound from outside of Flash ............................................................................301Turning a remote sound on and off .................................................................................302Adjusting volume with code..............................................................................................304Your turn: storm over Lake Superior ...............................................................................305Code snippet: visualize audio ..........................................................................................309

What you’ve learned................................................................................................................ 313

ix

Chapter 6: Text ....................................................................................................... 315 Fonts and typefaces ................................................................................................................ 316Adobe CoolType ......................................................................................................................319

Typefaces and fonts ......................................................................................................... 321Working with device fonts ....................................................................................................... 322 Embedding fonts ......................................................................................................................324The two text engines: TLF and Classic ..................................................................................328Types of text............................................................................................................................. 330

Read-only text properties .................................................................................................331Container and flow ............................................................................................................ 337Selectable and editable text .............................................................................................340TLF and ActionScript ........................................................................................................ 341Using TLF text as a button ...............................................................................................345

Hyperlinks and TLF ................................................................................................................. 349Using ActionScript to add hyperlinks to TLF text............................................................350

Checking spelling..................................................................................................................... 352Your turn: scrollable text ......................................................................................................... 355

Using the UIScrollBar component ...................................................................................355Rolling your own scroller ..................................................................................................356

What you have learned ........................................................................................................... 360

Chapter 7: Animation, Part 1 ................................................................................. 361 Shape tweening .......................................................................................................................363

Scaling and stretching ...................................................................................................... 363Modifying shape tweens...................................................................................................368Altering shapes .................................................................................................................369Shape hints .......................................................................................................................373Altering gradients .............................................................................................................. 377

Classic tweening......................................................................................................................379Rotation ............................................................................................................................. 379Classic tween properties ..................................................................................................381Scaling, stretching, and deforming ..................................................................................382Easing ................................................................................................................................ 384Custom easing ..................................................................................................................387

Using animation ....................................................................................................................... 395A closer look at the Timeline panel..................................................................................395Onion skinning .................................................................................................................. 397 Modifying multiple frames.................................................................................................400Combining timelines ......................................................................................................... 402

x

Motion guides.................................................................................................................... 408 Tweening a mask..............................................................................................................411Tweening Filter Effects .....................................................................................................413

Programmatic animation .........................................................................................................415Copying motion as ActionScript.......................................................................................416Using the keyboard to control motion..............................................................................419Creating random motion using ActionScript ...................................................................421

What you have learned ........................................................................................................... 426

Chapter 8: Animation, Part 2 ................................................................................. 427 Animating with the Motion Editor panel..................................................................................428

Getting acquainted: scaling and moving ......................................................................... 430Easing with graphs ...........................................................................................................437

Managing property keyframes ................................................................................................445Motion paths............................................................................................................................. 450

Manipulating motion paths ...............................................................................................450Motion tween properties ...................................................................................................454

Motion presets ......................................................................................................................... 455Inverse kinematics (IK)............................................................................................................ 458

Using the Bone tool ..........................................................................................................459Putting some “spring” in your bones ......................................................................................468

Animating IK Poses .......................................................................................................... 478Using the Bind tool............................................................................................................480Your turn: animate a fully rigged IK model...................................................................... 487

Inspiration is everywhere ........................................................................................................ 492 What you have learned ........................................................................................................... 493

Chapter 9: Flash Has a Third Dimension.............................................................. 495 What 3D really means in Flash (and what it doesn’t)............................................................496Understanding the vanishing point .........................................................................................498Using the 3D tools ................................................................................................................... 501

The 3D Rotation tool......................................................................................................... 501The 3D Translation tool ....................................................................................................506

Strategies for positioning content in 3D space ...................................................................... 512The parallax effect: traveling through space...................................................................512Use the 3D center point to your advantage .................................................................... 517Be aware of depth limitations...........................................................................................520

Your turn: simulate a photo cube............................................................................................ 522What you have learned ........................................................................................................... 526

xi

Chapter 10: Video................................................................................................... 527 Video on the Web .................................................................................................................... 529Video formats ........................................................................................................................... 530Encoding an FLV ..................................................................................................................... 532

Using the Adobe Media Encoder .....................................................................................532Batch encoding .................................................................................................................541Creating an F4V file .......................................................................................................... 542More Media Encoder Goodness ......................................................................................544

Playing an FLV in Flash CS5.................................................................................................. 546Using the wizard ...............................................................................................................546Using the FLVPlayback component ................................................................................552Playing video using ActionScript......................................................................................555Using the FLVPlayback control components .................................................................. 560Navigating through video using cue points ..................................................................... 562Adding captions with the FLVPlaybackCaptioning component ..................................... 567Preparing and using alpha channel video.......................................................................572Going full-screen with video .............................................................................................574

When video is not video ..........................................................................................................579Embedding video .....................................................................................................................579

Embedding video as a movie clip ....................................................................................581Interacting with video content ..........................................................................................582

Adding cue points .................................................................................................................... 583An alternate XML format for cue points........................................................................... 584Your turn: create XML captions for video........................................................................ 588

Your turn: play with alpha video ............................................................................................. 593Your turn: think big, really big! ................................................................................................ 597 What you have learned ........................................................................................................... 598

Chapter 11: Building Interfaces with the UI Components ................................... 601 Button component....................................................................................................................603

Using the Button component............................................................................................603Changing the Button component’s appearance .............................................................610

CheckBox component .............................................................................................................615ColorPicker component ...........................................................................................................617ComboBox component............................................................................................................619DataGrid component ...............................................................................................................622Label component .....................................................................................................................624List component......................................................................................................................... 624NumericStepper component ...................................................................................................626ProgressBar component ......................................................................................................... 628

xii

RadioButton component..........................................................................................................630ScrollPane component ............................................................................................................632Slider component.....................................................................................................................633TextArea component ...............................................................................................................635TextInput component...............................................................................................................636TileList component ..................................................................................................................637UILoader component ...............................................................................................................638UIScrollBar component ........................................................................................................... 641 What you have learned ........................................................................................................... 641

Chapter 12: XML (Dynamic Data) .......................................................................... 643 Writing XML.............................................................................................................................. 645Loading an XML file .................................................................................................................648Using E4X syntax .................................................................................................................... 649

Dots and @s...................................................................................................................... 650 Node types ........................................................................................................................654E4X filtering ....................................................................................................................... 656Double dots and more ......................................................................................................657Namespaces .....................................................................................................................659Your turn: time to explore XFL .........................................................................................661

What you have learned ........................................................................................................... 667

Chapter 13: CSS..................................................................................................... 669 Styling with CSS ...................................................................................................................... 671Loading external CSS .............................................................................................................676

Custom tags ...................................................................................................................... 684 Style inheritance ...............................................................................................................686Styling hyperlinks .............................................................................................................. 688 Embedded fonts ................................................................................................................690Selectors vs. the Properties panel...................................................................................693

What you have learned ........................................................................................................... 694

Chapter 14: Building Stuff ..................................................................................... 695 Loading content .......................................................................................................................697

Are we there yet?..............................................................................................................697Somebody stole my preloader .........................................................................................701

Building a slide show with components and XML .................................................................703A tour of the Beijing art district .........................................................................................704

xiii

Building an MP3 player with XML...........................................................................................711Setting up the external playlist .........................................................................................712Polishing up the symbols..................................................................................................713Wiring up the MP3 player controls...................................................................................720Evaluating and improving the MP3 player ...................................................................... 735

Going mobile ............................................................................................................................ 737A quick tour of Device Central .........................................................................................737Package the game as an Android AIR app.....................................................................750Build more stuff ................................................................................................................. 756

What you have learned ........................................................................................................... 756

Chapter 15: Optimizing and Publishing Flash Movies......................................... 757 Flash’s love-hate Internet relationship ...................................................................................758

This “Internet” thing........................................................................................................... 759 Enter the World Wide Web...............................................................................................760Bandwidth..........................................................................................................................760So, who are these folks we call users? ...........................................................................762

Streaming ................................................................................................................................. 763The Bandwidth Profiler ............................................................................................................ 765

Simulating a download .....................................................................................................765Pinpointing problem content.............................................................................................769Can I get that in writing?................................................................................................... 770

Optimizing and fine-tuning your Flash movies ......................................................................771Planning your project ........................................................................................................ 771Distributing the weight ...................................................................................................... 776Optimizing elements in the movie....................................................................................778

Publishing and web formats.................................................................................................... 783Flash .................................................................................................................................. 784HTML ................................................................................................................................. 785Animated GIFs ..................................................................................................................786QuickTime ......................................................................................................................... 790

It’s showtime! ........................................................................................................................... 791Publish settings ................................................................................................................. 792 Publishing the butterfly garden ........................................................................................803Publishing Flash movies containing linked files.............................................................. 805

What you have learned ........................................................................................................... 807

Index ....................................................................................................................... 809

xiv

About the Authors

Tom Green is currently Professor, Interactive Media through the School of Media Studies at the Humber Institute of Technology and Advanced Learning in Toronto, Canada. He has written numerous books on Adobe technologies and several hundred tutorials for numerous magazines and websites including activetutsplus.com, layersmagazine.com, Community MX, and Computer Arts. Tom is also an Adobe Community Professional and an Adobe Education Leader. He has spoken and lectured at more than 20 conferences and post-secondary institutions internationally including Adobe Max, FITC, SparkEurope, and the Central Academy of Fine Arts in Beijing, China. In his spare time, you can catch him hiking a trail with the Cub Scout group he has led for the past 15 years or paddling a lake in Northern Ontario. You can contact Tom at [email protected].

Tiago Dias discovered Flash around the time of Flash 3, after seeing a Flash site for the first time. He started off by doing freelance work on the side from his day job as a network/systems engineer. Today he works as a Senior Flash Platform Developer at Publicis Modem, the digital unit of Publicis. Previously he worked as a video producer and Flash developer at a Corporate Television company in Zurich.

Besides working and writing, Tiago is an Adobe Community Professional and one of the co-managers of the Swiss Flash User Group (SFUG) and has spoken at such conferences as FITC and FATL on various topics.

In his free time, he writes tutorials on Flash, Flex, AS3, and new technologies/libraries for various communities. To relax, he tries to go snowboarding every time the sun is shining in the Swiss Alps or

hops on a plane and flies to a sunny and warm destination to go scuba diving. He currently lives and works in Zurich, Switzerland.

xv

About the Technical Reviewers

Cheridan Kerr has been involved in web development and design since 1997 when she began working on a research team for the Y2K Millennium Bug. It was here she learned about the Internet and promptly fell in love with the medium. In her career, she has been responsible for websites in the early 2000s such as Weight Watchers Australia and Quicken.com.au, and she has worked as a creative services manager of Yahoo!7 in Australia on clients such as Toyota, 20th Century Fox, and Ford. Currently, she is working as the head of digital for an Australian advertising agency.

Kristian Besley is a Flash and web developer currently working in education and specializing in games/interactivity and dynamically driven content using Flash, PHP, and .NET (not all at the same time, obviously!). He also lectures in interactive media.

Kristian has produced freelance work for numerous clients including the BBC, Heinemann, and BBC Cymru. He has written a number of books for friends of ED, such as working on the Foundation Flash series, Flash MX Video (ISBN-13: 978-1-59059-172-7), Flash ActionScript for Flash 8 (ISBN-13: 978-1-59059-618-0), and Learn Design with Flash MX (ISBN-13: 978-1-59059-157-4). He was also a proud contributor to the amazing Flash Math Creativity books and has written for Computer Arts magazine.

Kristian currently resides with his family in Swansea, Wales and is a fluent Welsh speaker.

xvi

Acknowledgments

In the acknowledgments for the CS3 version of this book, I said, “Working with a coauthor can be a tricky business. In fact, it is a little like a marriage. Everything is wonderful when things are going well, but you never really discover the strength of the relationship until you get deep into it.” You may notice there is a new name, Tiago Dias, on the cover, which indicates that David Stiller, my previous coauthor, had to back out of this project because his Flash development business took off, and he simply didn’t have the time necessary to devote to this book.

Four years ago Tiago and I explored the intersection of After Effects and Flash when we worked together on another friendsofED title From After Effects to Flash: Poetry in Motion Graphics. When Dave graciously stepped aside, who better to step in than Tiago?

Having kept in close touch for the four years between our first book and this one, we had developed a close personal and professional relationship, which made the transition between coauthors seamless. As well, Tiago brought a fresh pair of eyes to the process, and there were several times when I would get e-mails that started off with “Dude, let’s try this approach…” when I went sideways instead of forward. Like David, Tiago gave me a good shake when I wasn’t understanding a code block or technique; these inevitably started with, “It’s really very simple, Tom,” and he would lay out exactly what I was missing. When we finished the book, I reflected on the process and discovered that Tiago and I had picked up exactly where we left off four years ago, and that, my friends, is the mark of an amazing partnership.

Next up is our editor Ben Renow-Clark. There seems to be this generalized misconception that the relationship between an editor and a writer is adversarial. Actually, the best work is done when the relationship is the exact opposite, and I am so grateful to have just that relationship with Ben.

Another group of people that have had a profound influence on this book are my students at the college where I teach and those of you I have met at conferences, online or through my tutorial efforts. I am deeply grateful for your patience when I tried out some of the exercises in this book and you reacted negatively or positively. It showed me where I was doing something right or where I needed to start over again. Also, hearing from my education peers around the world who use this book in their classrooms didn’t hurt when it came to actually writing the exercises and even determining their order.

Finally, writing a book means I disappear into my office and generally become moody and difficult to live with as I mull over some aspect of an exercise or the order of a chapter. It takes a very unique individual to put up with that, let alone understand why, and my wife, best friend, and life partner for more than 30 years, Keltie, has somehow put up with it.

Tom Green

In 2009, Tom and I got together at Adobe’s MAX 2009 for a rather “quick” chat at one of the lunch tables. The whole conversation was relatively short—15 to 20 minutes—and over that space of time we reviewed all the chapters of this book, their content, and who was doing what. The result of that conversation is the book you are holding. Now you might think that is crazy—our having one brief chat. It might seem like that to you, but for us it was normal. The real discussions happened when we switched on our webcams and

xvii

saw each other—one in his home office and me in my living room, garden, office, or wherever I was at that time. It was fun, and we laughed a lot during our Skype conversations.

As Tom already mentioned, we worked on a book together four years ago, and since then we have developed a great partnership. We understand each other quite well, and, when one side knows what the other is thinking or wants to accomplish, that leads to an awesome workflow. But as it is, life is not a piece of cake; sometimes things don’t go the way they should, and that’s where your good friends, and in this case especially Tom, come in. He backed me up during the course of this book, something that I was a bit scared of, and, because of my job, I couldn’t always be there for him. If I were asked again to write a book, I think I would only do it with this old man! No one else managed to wake my creativity while writing books. Tom, you are a great person and a great mentor.

Next up I would like to thank Mischa Plocek and Pascal [P] Baumann for donating some of their work to be used in this book. Thank you guys for all your work and time invested doing what you guys can do best! Marcel, thanks for giving me the spare time I needed and providing me with some ideas; I don’t know how to thank you for this, but I think I can come up with something.

Last, but not least, writing books can be a challenge. You constantly think day and night of what you have to deliver the next day. Thanks to the time zones, I always had a few more hours to work on until Tom woke up. I normally close myself in a state of writing in the morning, writing during lunch, and writing any time when I’m home. There is not really a break, and I become very impatient and difficult to be around. It needs lots of nerves and time to handle me during that time, and I can’t thank my girlfriend, Anjanee, enough for supporting me and trying to handle my difficult moods during the process of the book and all the other situations in life. Thank you!

Tiago Dias

xviii

Preface

I can remember the day as clear is if it were just yesterday. I was walking by my boss’s 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.

What I didn’t expect is to be writing books, articles, and tutorials around Flash for the past 10 years. I also didn’t expect that my fascination with Flash would take me around the world speaking at conferences or lecturing at universities from Amsterdam to Wu Han on the subject of Flash and web-based media. It has been quite the experience, and Flash CS5 makes things even more fascinating.

Flash CS5 is one of the more important versions in the history of the product. Flash CS5 has evolved into a serious design tool able to handle everything from simple motion graphics to broadcast-quality animations. It also marks the point where Flash is fully integrated into the Adobe product line up. The Motion Editor, a rejigged Media Encoder, the TextLayoutFramework, and a fist full of sophisticated animation tools are evidence of that.

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, we 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 the new Springs feature to a rectangle on the Flash stage. It is more effective when you do exactly the same thing to bend trees. Anybody can dryly explain 9-slice scaling, but it becomes less techie when you apply it to a Chinese olive seller. Nested movie clips 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.” Interested in going out on the bleeding edge of Flash and preparing a project for an Android-based device? Whack-A-Bunny makes it interesting and fun.

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.

xix

Book structure and flow To start, this is not a typical Foundation book. There is no common project that runs throughout the book. Instead, each chapter contains a number of exercises to help you develop some “Flash chops,” and then we turn you loose in the “Your turn” section of each chapter.

We start by dropping you right into the application and creating a small Flash movie located in a “butterfly garden” (told you we were having fun). This chapter familiarizes you with the Flash workspace and the fundamentals of using Flash Professional CS5. Chapter 2 introduces you to working with the graphic tools and with graphics files and finishes with your creating a banner ad for an ice hotel.

Chapter 3 introduces you to symbols and libraries in Flash CS3. In this chapter, you learn how to create and use symbols, and we even let an olive seller explain how 9-slice scaling works. With those fundamentals under your belt, we show you how to share symbols and libraries between movies and how to manipulate symbols with filters and blend effects, and along the way you travel from a park bench in Paris to a wall in Adobe’s San Jose headquarters, discovering how to create some rather powerful effects in your Flash movies. The chapter finishes by showing you how to use masks to your advantage in Flash.

At this point in the book, you have pretty well mastered the fundamentals. The rest of the book builds upon what you have learned. Chapter 4 picks you up and throws you into the ActionScript 3.0 pool. Chapter 5 starts by explaining how to use audio in Flash and finishes with your constructing an MP3 player. Chapter 6 reinforces the message that “text isn’t the gray stuff that surrounds your animations.” We show you how it is both serious and fun by stepping through how to create scrolling text and how to use the TextLayoutFramework to bring professional-level typography into your work.

Chapter 7 is one of the more important chapters in the book because Flash’s roots were as an animation application. You are going to learn the basics here, but don’t expect to be shoving boxes and circles around. You will be banging hammers, eating apples, dropping rabbits, fixing a neon sign and lighting it up, and setting a butterfly in motion. Did we mention we believe in having fun? Chapter 8 continues the motion theme by getting you deep into the new Motion Editor, and Chapter 9 walks you through the 3D tools introduced in Flash CS4 and improved upon in Flash CS5.

From animation, we move into video in Flash. In Chapter 10, we show the entire process from encoding to upload. In fact, the chapter finishes with your adding captions and a full-screen capability to a Superman movie. Along the way, you will visit heaven and meet a “Girl with Stories in Her Hair.”

Chapters 11, 12, and 13 give you the chance to play with all of the Flash user interface components, actually style a Flash movie using Cascading Style Sheets, and explore how XML gives you a huge amount of flexibility when it comes to adding dynamic data to your movie.

Chapter 14 is where you get to pull it all together and build everything from a simple preloader to a full-bore game designed to be played on an Android device.

The final chapter focuses on the end game of the design process. It shows you a number of the important techniques you need to know that will keep your movies small and efficient, how to create the SWF that will be embedded into a web page, and how to keep that process as smooth as possible.

Finally, Tiago and I are no different from you. We are learning about this application and what it can and cannot do at the same time as you. Though we may be coming at it from a slightly more advanced level,

xx

there is a lot about this application we’re still learning. If there is something we have missed or something you don’t quite understand, by all means contact us. We’ll be sure to add it to the book’s site.

Our final words of advice for you are these:

The amount of fun you can have with this application should be illegal. We’ll see you in jail!

Layout conventions To keep this book as clear and easy to follow as possible, the following text conventions are used throughout.

Important words or concepts are normally highlighted on the first appearance in bold type.

Code is presented in fixed-width font.

New or changed code is normally presented in bold fixed-width font.

Pseudocode and variable input are written in italic ixed-width font.

Menu commands are written in the form Menu ➤ Submenu ➤ Submenu.

Where we want to draw your attention to something, we’ve highlighted it like this:

Ahem, don’t saw we didn’t warn you.

Sometimes code won’t fit on a single line in a book. Where this happens, we use an arrow like this: �

This is a very, very long section of code that should be written all � on the same line without a break