Flash MX 2004 was pri-marily focused on providing support in the tool for the then-new ActionScript 2.0 language.. Keeping the cycle going, Flash CS3’s main thrust was to provide support
Trang 3Learning Flash CS4 Professional
Rich Shupe
Trang 4Learning Flash CS4 Professional
by Rich Shupe
Copyright © 2009 Rich Shupe All rights reserved
Printed in Canada
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472
O’Reilly Media books may be purchased for educational, business, or sales promotional use Online editions are also available for most titles (safari.oreilly.com) For more information, contact our corporate/institutional sales department:
800-998-9938 or corporate@oreilly.com.
Editor: Steve Weiss
Production Editors: Chris Meredith and Rachel Monaghan
Developmental Editor: Linda Laflamme
Copy Editor: Amy Thomson
Technical Reviewers: Thomas Yeh and Anselm Bradford
Proofreader: Rachel Monaghan
Interior Designer: Ron Bilodeau
Cover Designer: Karen Montgomery
Indexer: Julie Hawks
Print History:
April 2009: First Edition
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc This book’s trade dress is a trademark of O’Reilly Media, Inc Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and O’Reilly Media, Inc was aware of a trademark claim, the designations have been printed in caps or initial caps
While every precaution has been taken in the preparation of this book, the publisher and author assume no ity for errors or omissions, or for damages resulting from the use of the information contained herein
responsibil-ISBN: 978-0-596-15976-4
[F]
Trang 5Adobe Developer Library, a copublishing partnership between O’Reilly Media Inc.
and Adobe Systems, Inc., is the authoritative resource for developers using Adobetechnologies These comprehensive resources offer learning solutions to help devel-opers create cutting-edge interactive web applications that can reach virtually any-one on any platform
With top-quality books and innovative online resources covering the latest tools forrich-Internet application development, theAdobe Developer Library delivers expert
training, straight from the source Topics include ActionScript, Adobe Flex®, AdobeFlash®, and Adobe Acrobat® software
Get the latest news about books, online resources, and more at library.com.
Trang 7adobedeveloper-Foreword xv
Preface xvii
Chapter 1 Interface Essentials 1
Introduction 1
Getting to Know the Flash CS4 Interface 2
Creating a New Document 2
Using the New Application Window 3
Understanding Panels 6
Understanding the Timeline 11
Customizing Your Interface 13
Selecting and Editing a Workspace 13
Minimizing Panels 14
Grouping and Docking Panels 14
The Preferences Dialog 15
Customizing the Tools Panel 17
Keyboard Shortcuts 18
Project Progress 19
Creating Your First FLA 20
Importing Your First Asset 20
Creating Your First Shape 21
Testing Your File 22
Creating a Guide Layer 22
Adding Utility Layers 23
Saving Your File As a Template 23
The Project Continues 24 Contents
Trang 8vi
Chapter 2 Creating Graphics 25
Introduction 25
Drawing Modes 26
Merge Drawing Mode 26
Object Drawing Mode 27
Grouping and Breaking Apart 28
Drawing au Naturel 29
Drawing with Bézier Curves 29
Selecting 30
Using Fills and Strokes 30
Selecting Separately 30
Stroke Properties 31
Mining Properties with Tools 32
Working with Color 33
Pop-Up Palette 33
Swatches Panel 34
Color Panel 34
Kuler Panel 35
Using Context-Sensitive Tool Options 35
Paint Modes 35
Erase Modes 36
Transforming Assets 36
Free Transform Tool 36
Transform Panel 37
Gradient Transform Tool 37
Creating Static Text 38
Using the Spray Brush 39
Creating a Symbol 40
Project Progress 40
Creating a New File and Container Movie Clip 42
Adding Title Text and Underline 42
Adding Skills Text and Underline 44
Cascading Rectangles Primitives 45
Applying a Gradient to the Cascade 46
Adding Grime 47
The Project Continues 48
Trang 9Chapter 3 Using Symbols 49
Introduction 49
Symbol Types 50
Button 50
Movie Clip 55
Graphic 57
Converting Symbol Types 57
Creating and Editing Symbols 59
Convert to Symbol and Edit in Place 59
Insert Symbol and Edit Selected 59
Reusing Symbols 60
Using the Deco Tool 61
Vine Fill 61
Grid Fill 62
Symmetry Brush 63
Project Progress 64
Creating the Sound Controller .65
Adding ActionScript-Controlled Animation 69
The Project Continues 71
Chapter 4 Importing Graphics 73
Introduction 73
Importing Graphics 73
Importing Nonnative Formats 74
Importing from SWF 75
Importing from Adobe Photoshop 75
Importing from Adobe Illustrator 79
Importing from Other Native Formats 82
Importing an Image Sequence 83
Working with Bitmaps 83
Publish Settings 84
Bitmap Properties 84
Tracing a Bitmap 85
Using a Bitmap As a Tile 87
Project Progress 87
Importing the Interface Shell 87
Importing the Background 90
Importing the Logo 91
Importing the Lab Screen 92
The Project Continues 94
Trang 10viii
Chapter 5 Animation 95
Introduction 95
Knowing the Timeline 96
Layers 96
Frames 98
Frame Editing Controls 100
Creating Frame-by-Frame Animations 100
Editing Multiple Frames 101
Copying and Pasting Frames 101
Swap Symbols 102
Creating a Shape Tween 103
Shape Hints 105
Adding a Layer Mask 106
Creating a Motion Tween 107
Editing the Motion Path 108
Drawing a Motion Guide 109
Color Effects 112
Using Motion Presets 113
Copying Motion 114
Using the Motion Editor Panel 114
Adding Property Keyframes in the Motion Editor 116
Editing Property Curves in the Motion Editor 116
Easing 117
Adding Easing with the Motion Editor 118
Creating a Custom Easing Preset 119
Creating a Classic Tween 122
Adding Easing with the Properties Panel 122
Custom Easing 123
Classic Motion Guide 124
Project Progress 125
Inner Section Timeline Structure 126
Project-Wide Timeline Structure 130
Button Script 135
Testing Your Work 136
The Project Continues 136
Trang 11Chapter 6 ActionScript Basics 137
Introduction 137
How Much ActionScript Is Covered in This Book? 139
Introducing ActionScript Interface Elements 140
Actions Panel 140
Output Panel 142
Basic Script Grammar 143
Introducing Properties 143
Introducing Methods 143
Introducing Events and Event Listeners 144
Basic Syntax Issues 144
Dot Syntax 144
Case Sensitivity 145
Execution Order 146
Use of the Semicolon(;) 146
Evaluating an Expression 146
Absolute Versus Relative Addresses 146
Comments 147
Checking and Formatting Your Scripts 148
Variables and Data Types 150
Casting Data Types 151
Operators 152
Scope and this 153
Functions 153
Arguments 154
Return Values 154
Conditionals 155
if 155
switch 157
Loops 158
for Loop 158
while Loop 159
A Loop Caveat 160
Arrays 160
Multidimensional Arrays 161
Associative Arrays and Objects 162
Properties 163
Methods 165
Trang 12x
Events 165
Event Listeners 166
Using Mouse Events to Control Properties and Methods 168
Frame Events 170
Removing Event Listeners 171
The Display List 172
Adding and Removing Children 172
Using addChild() 173
Adding Symbol Instances to the Display List from the Library 173
Using addChildAt() 175
Removing Objects from the Display List and from Memory 176
Finding Children by Position and by Name 177
Casting a Display Object 178
Timeline Control 179
Frame Labels 181
Frame Rate 183
Project Progress 184
Chapter 3: The Deco Tool 184
Chapter 5: The Portfolio Project Navigation 185
The Project Continues 186
Chapter 7 Filters and Blend Modes 187
Introduction 187
Bitmap Caching 187
The Properties Panel 188
The ActionScript Method 188
Filters 189
Filter Inventory 189
The Properties Panel 191
The ActionScript 191
Filters in Practice 192
Blend Modes 194
Blend Mode Inventory 194
The Properties Panel 196
ActionScript 197
Blend Modes in Practice 197
Alpha Masks 197
The Timeline Limitation 198
The Blend Mode Solutions 198
The ActionScript Solution 198
Trang 13Project Progress 199
Confirming the Imported Blend Mode 199
Filters 199
The Project Continues 202
Chapter 8 3D 203
Introduction 203
Moving Objects in 3D Space 204
Translating 3D Objects 205
Rotating 3D Objects 205
Transforming Multiple Objects in 3D Space 207
Changing the 3D Center Point 208
Global Versus Local 3D Transformations 208
Global 3D Environment Settings 209
Vanishing Point 209
Perspective Angle 211
Taking Advantage of Global 3D Settings with Movie Clip Containers 212
Animating 3D Properties 213
Depth Management 215
Parallax Scrolling 216
Using ActionScript to Change 3D Properties 217
Practical Demonstrations 217
Project Progress 219
Adding Depth for Parallax Scrolling 220
Animating the Gallery 221
Adding ActionScript Control 222
Adding a Layer Mask 223
Adding the Gallery to the Main Project File 224
The Project Continues 224
Chapter 9 Components 225
Introduction 225
Adding and Configuring Components 226
Functionality Without Programming 227
Scrolling Text 227
Adding a Pinch of ActionScript 228
Triggering Actions with Buttons 228
Working Hand-in-Hand with Code 229
Navigating with Menus 229
Skinning UI Components 233
Trang 14xii
Project Progress 233
Loading an External Graphic at Runtime 233
Display Details of a Larger Image 234
The Project Continues 236
Chapter 10 Inverse Kinematics 237
Introduction 237
Anatomy of an Armature 238
Using the Bone Tool with Movie Clips 239
Authortime Mode 240
Tweening Armatures 241
Armature Easing 242
Runtime Mode 243
Joint Rotation and Translation 244
Constraining Joint Rotation 244
Enabling Joint Translation 247
Transforming Movie Clips and Armatures 248
Using the Bone Tool with Shapes 248
Using the Bind Tool 250
Adjusting Points 250
Basic ActionScript 251
Supporting Runtime Armature Use Beyond Frame 1 251
Posing an Armature with Code 252
Project Progress 254
The Project Continues 259
Chapter 11 Text 261
Introduction 261
Components 262
Using the Component Inspector Panel to Configure Text Components 262
Using ActionScript to Configure Text Components 263
Configuring Text Fields with the Flash Interface 265
Dynamic Text 265
Input Text 268
Static Text 269
Resizing Text Fields 270
Configuring Text Fields with ActionScript 270
Dynamic Text 270
Input Text 271
Formatting Text 271
Fonts 272
ActionScript 275
Trang 15Using HTML 277
Using CSS 278
Loading Text 280
Using InDesign and XFL 282
Project Progress 283
Cosmetic Assets 283
Dynamic Text Field 284
Input Text Field 285
The Project Continues 286
Chapter 12 Audio 287
Introduction 287
Supported File Formats 287
Importing Audio 288
External Audio Playback 288
Compression 289
Compressing External Sounds 290
Internal Asset-Specific Sound Properties 291
Internal File-Wide Publish Settings 292
Timeline Use 293
Sync Types 294
Repeating and Looping 295
Editing a Sound 295
Setting Volume and Pan 295
Using an External Editor 297
ActionScript Use 297
Playing a Library Sound 297
Playing an External Sound 298
Setting Volume and Pan 299
Visualizing Volume 299
Project Progress 300
Scripting the Sound Controller 300
The Project Continues 302
Chapter 13 Video 303
Introduction 303
Video Formats 304
Encoding Software 305
On2 Flix 305
Sorenson Squeeze 306
Adobe Media Encoder 307
Playing Video with the FLVPlayback Component 315
Trang 16xiv
Full-Screen Video 317
Captioning Video 318
Streaming Versus Progressive Download 319
Embedding Videos in a SWF 320
When to Embed 320
When Not to Embed 322
Project Progress 323
Adding Video 323
The Project Continues 324
Chapter 14 Publishing and Deploying 325
Introduction 325
Using a Preloader 325
The Assets 326
The ActionScript 327
Testing Your Preloader 328
Project Progress Preloader 329
Distributing External Assets 329
Deploying for Web Browsers 330
Publish Settings: Format 330
Publish Settings: Flash 331
Publish Settings: HTML 334
Deployment 337
Project Progress HTML 337
Deploying for AIR 339
Publish Settings 340
Deployment 346
Project Progress AIR 348
What’s Next? 350
Index 351
Trang 17At the time of this writing, Flash CS4 has been out in the world for
approxi-mately six months In that time, one of my responsibilities at Adobe has been
to help the Flash community get up to speed with all of the new changes Like
any software release that includes a significant number of new features, it has
been a bumpy road for some people as they adapt to the new ways of doing
things Flash CS4 has undergone some major changes to existing features, in
addition to introducing some brand new capabilities
Just for some background, the central focus for each release of the Flash
authoring tool has tended to be cyclical in nature Flash MX 2004 was
pri-marily focused on providing support in the tool for the then-new ActionScript
2.0 language Following that, Flash 8 unveiled a slew of new designer options,
like filter effects, bitmap manipulation, and alpha channel video support
Keeping the cycle going, Flash CS3’s main thrust was to provide support
for the great new ActionScript 3.0 language Noticing the pattern here? Well,
designers will be happy to know that the cycle remains intact Flash CS4 is
packed with features dedicated to the creative professional
Probably the biggest change, and the thing you will notice right off the bat, is
the entirely new animation and timeline model For years the Flash
commu-nity has been asking for an animation system similar to that found in tools
like After Effects Well, Adobe has listened and has completely revamped the
way in which you create timeline animations The repetitive creation and
modification of keyframes is a thing of the past, as Flash will now
automati-cally create the necessary keyframes as you manipulate your objects on the
timeline A full-featured motion editor has also been added, giving you fine
control over your animations
Another request that we have gotten for years is for 3D support within Flash
With Flash Player 10, we now have the capability to manipulate any display
object in 3D space There are some new tools in Flash CS4 to support these
features, and they make creating 3D effects no more difficult than creating
any other type of animation
Trang 18xvi
Character animators will be very happy to find support for inverse ics (IK) in Flash CS4 IK allows designers to create bones between movie clips, and within shapes, to create animations that adhere to the constraints of a skeletal structure This system is not just for characters, either, and can be used to create a wide array of animation effects
kinemat-I could go on and on talking about the features in this exciting new version
of Flash I could talk about the new user interface, the new Spray and Deco drawing tools, the new Project panel, and the enhanced integration with Adobe Flex I could do that, but I’m going to let a much better writer than myself, Rich Shupe, take over from here
I remember seeing Rich speak at my very first Flash Forward conference in New York and was extremely impressed with his knowledge and methods
of teaching Through my own years of teaching Flash, I know how hard
it is to explain some of the seemingly unexplainable parts of our amazing
platform Rich definitely has a knack for finding ways to make these areas understandable
In addition to the book that you’re holding right now, Rich is also the writer
of Learning ActionScript 3.0: A Beginner’s Guide (O’Reilly), which I consider
to be one of the best ActionScript books ever written In fact, you will find a quote from me on the cover of newer versions of the book stating just that Rich’s writing style and true mastery of Flash makes learning the new ver-sions of Flash and ActionScript easier than I ever imagined That book also makes an excellent companion to this one, giving you a well-rounded library
of knowledge on Flash
I would also like to take a moment to thank O’Reilly for being committed to producing this book in full color I can’t tell you how much more engaging a book like this is when the code samples and screenshots look exactly as they
do on your own computer screen Beyond just being pretty to look at, the full-color treatment greatly enhances the learning experience as well
Rich has structured this book in a project format, which is no easy task I find
it to be really refreshing that readers will actually be building something ful at the same time that they are learning the new software While reading a prerelease version of this book, I actually learned many new techniques that
use-I didn’t know about—and use-I work for Adobe—so use-I’m confident that you will find it an extremely rewarding experience
—Lee Brimelow
Flash Platform Evangelist, Adobe
San Francisco, 2009
Trang 19A Dynamic Duo
The book you hold in your hand is one of a pair It’s not a left sock or a single
cufflink, because it’s unique and it’s still of use without its mate It’s more like
a fraternal twin or, perhaps more appropriately, the A–M volume of two-tome
encyclopedia The volumes are linked, and they share common ancestry and
a common vision, but they exist perfectly well on their own
The book you’re reading now is your first ace in the proverbial hole, and
focuses on the Flash CS4 Professional application This book will teach you
how to draw and import graphics; use text, sound, and video; and even
posi-tion objects in 3D space and create a moveable skeletal arm—all without any
programming at all
The second bullet is Learning ActionScript 3.0 (O’Reilly) and covers
ActionScript, Flash’s internal scripting language responsible for making Flash
projects interactive Learning ActionScript 3.0 picks up ActionScript where
this book leaves off It takes an introductory chapter nestled within 13 other
chapters of application goodness and expands it into coverage that includes
the bulk of ActionScript 3.0’s core features
Why were these books conceived as a pair? Simply put, each book was
designed to better deliver its share of the knowledge lode Each book works
better independently than if both volumes were encumbered by tying
every-thing together into one 700-page disc-slipper This book introduces the
Flash application to users who may never have seen it before Its companion
volume assumes familiarity with the Flash interface and is, therefore, able to
concentrate solely on the ActionScript language
Trang 20xviii
Can I See Your Portfolio?
Don’t be deceived by these carefully laid plans In addition to having an independent streak, this book also teaches its fair share of ActionScript Why bother when its companion volume is waiting to be read? For one reason, ActionScript is as much a part of Flash as its Timeline panel Writing a book about Flash without talking about ActionScript is like writing about Sherlock Holmes and neglecting to mention Watson
For another reason, this book is project-based and you can’t get very far with
a project of any significant scale without using ActionScript Its project is a leading player in this book, to be sure, but it’s not the only act in town In each chapter, topics are first introduced to you in short, digestible exercises that convey an idea, demonstrate a tool, or explain a script’s syntax Only at the end of each chapter, in a reinforcing, real-world scenario, are these skills applied to the ongoing portfolio you will build by book’s end
The portfolio itself is unique, too Designed not to hinge on a conventional project that trudges through every chapter, this book takes a different path
on its way to your studio The project herein was conceived to be more than
a standard top- or left-frame navigation website The portfolio was created to highlight all the major features that Flash CS4 Professional has to offer and
to push the limits of the average Flash authoring experience
Assets were intentionally designed to create problems to solve, such as how best to add expressive movement to a complex animation and how to opti-mize large files for quicker download Design ideas were chosen because they offered opportunities to solve these and other problems in creative ways Yes, the book was planned so that you don’t have to invest a lot of time in a project you have no interest in building Yet if you do choose to practice what you’ve learned in each chapter by applying your new skills to on ongoing project, you’ll hone your chops that much quicker
Who This Book Is For
This book is aimed at Flash designers and developers who are picking up Flash CS4 Professional for the first time, as well as users upgrading from prior versions who are looking to acquaint themselves with the version’s new features
No prior experience with Flash is necessary to enjoy this book, as you learn the Flash interface from the ground up, but there are plenty of new features
of which veteran Flash designers and developers can take advantage
Reading through this preface and looking over a few sample chapters will increase the chances that you’ll be happy with the content and straightfor-ward approach adopted herein