Tải bản đầy đủ (.pdf) (648 trang)

foundation actionscript for flash 8

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (8.89 MB, 648 trang )

Foundation ActionScript
for Flash 8
Kristian Besley
Sham Bhangal
David Powers
with Eric Dolecki
6188FM.qxd 3/8/06 12:48 PM Page i
Lead Editor
Chris Mills
Technical Reviewers
Kristian Besley and David Powers
Editorial Board
Steve Anglin, Dan Appleman,
Ewan Buckingham, Gary Cornell,
Jason Gilmore, Jonathan Hassell,
James Huddleston, Chris Mills,
Matthew Moodie, Dominic Shakeshaft,
Jim Sumser, Matt Wade
Project Manager
Denise Santoro Lincoln
Copy Edit Manager
Nicole LeClerc
Copy Editors
Ami Knox and Nicole LeClerc
Assistant Production Director
Kari Brooks-Copony
Production Editor
Kelly Winquist
Compositor
Dina Quan


Artist
Kinetic Publishing Services, LLC
Proofreader
Linda Seifert
Indexer
Julie Grady
Cover Image Designer
Corné van Dooren
Interior and Cover Designer
Kurt Krames
Foundation ActionScript for Flash 8
Copyright © 2006 by Kristian Besley, Sham Bhangal, and David Powers
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-59059-618-0
ISBN-10 (pbk): 1-59059-618-8
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked
name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of
infringement of the trademark.
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013.
Phone 1-800-SPRINGER, fax 201-348-4505, e-mail , or visit www.springeronline.com.
For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710.
Phone 510-549-5930, fax 510-549-5939, e-mail , or visit www.apress.com.
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.
Credits

Manufacturing Director
Tom Debolski
6188FM.qxd 3/8/06 12:48 PM Page ii
About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
About the Cover Image Designer . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Chapter 1 Interactive Flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 2 Making Plans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Chapter 3 Movies That Remember . . . . . . . . . . . . . . . . . . . . . . . . . 59
Chapter 4 Movies That Decide for Themselves . . . . . . . . . . . . . . . 105
Chapter 5 More Power, Less Script . . . . . . . . . . . . . . . . . . . . . . . . 139
Chapter 6 Movies That Remember How to Do Things . . . . . . . . . . 185
Chapter 7 Objects and Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
Chapter 8 Objects on the Stage . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Chapter 9 Reusable Code and Realistic Movement . . . . . . . . . . . . 299
Chapter 10 Games and Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
Chapter 11 Drawing API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
Chapter 12 Adding Sound to Flash . . . . . . . . . . . . . . . . . . . . . . . . . 453
Chapter 13 Loading Dynamic Data with XML . . . . . . . . . . . . . . . . . 487
Chapter 14 Finishing the Futuremedia Case Study . . . . . . . . . . . . . 525
Chapter 15 Advanced ActionScript: Components and Classes . . . . 559
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607
iii
CONTENTS AT A GLANCE
6188FM.qxd 3/8/06 12:48 PM Page iii
6188FM.qxd 3/8/06 12:48 PM Page iv
About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
About the Cover Image Designer . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Chapter 1 Interactive Flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Giving your movies instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Working with the Actions panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Direct typing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Who are you talking to? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Controlling movie clips on the stage . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Listening to what your movies are telling you . . . . . . . . . . . . . . . . . . . . . . . . 20
Events in Flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
External events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Internal events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Introducing event handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Nesting spiders—argh! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Animating movie clips with ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . 25
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Chapter 2 Making Plans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Defining the problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Keep your ideas in a safer place than your head . . . . . . . . . . . . . . . . . . . . 32
Storyboarding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Building your ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Thinking from the top down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Thinking from the bottom up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Flowcharting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Book project: Introducing the Futuremedia site . . . . . . . . . . . . . . . . . . . . . . 44
Solving problem 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Solving problem 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Solving problems 3 and 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Parting shots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
v
CONTENTS

6188FM.qxd 3/8/06 12:48 PM Page v
Chapter 3 Movies That Remember . . . . . . . . . . . . . . . . . . . . . . . . . 59
Introducing variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Values and types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Creating variables and using them with literals and expressions . . . . . . . . . . . . 63
Naming variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Creating variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Using literal values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Using expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Input and output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Using string expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Working with numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Other uses for numeric expressions . . . . . . . . . . . . . . . . . . . . . . . . . 81
Working with Boolean values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Logic operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Reasons for using arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Arrays let you store related information together . . . . . . . . . . . . . . . . . 86
Arrays let you hold information in a specific order . . . . . . . . . . . . . . . . . 86
Arrays let you index information . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Arrays let you link information . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Creating a new array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Typing an array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Using variable values as offsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Book project: Starting the Futuremedia site design . . . . . . . . . . . . . . . . . . . . . 92
What you’re going to do . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
What you’re going to learn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Choosing and setting the stage size . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Setting up the timeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Creating layout guides . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

Adding the position and status text . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Choosing a font . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Adding the text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Embedding the font . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Parting shots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Chapter 4 Movies That Decide for Themselves . . . . . . . . . . . . . . . 105
Decision making . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Making decisions in ActionScript: The if action . . . . . . . . . . . . . . . . . . . . 107
Defining a decision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Alternative actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Acting on alternatives: The else action . . . . . . . . . . . . . . . . . . . . . . . . . 118
More than one alternative: The else if action . . . . . . . . . . . . . . . . . . . . . 119
Handling lots of alternatives: The switch action . . . . . . . . . . . . . . . . . . . . 123
Switching without breaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Organizing your code in the correct order . . . . . . . . . . . . . . . . . . . . . . . . . 136
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
CONTENTS
vi
6188FM.qxd 3/8/06 12:48 PM Page vi
Chapter 5 More Power, Less Script . . . . . . . . . . . . . . . . . . . . . . . . 139
Timeline loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
ActionScript loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
while loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Useful things to do with while loops . . . . . . . . . . . . . . . . . . . . . . . . . . 142
for loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
init . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
next . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Some useful examples of for loops . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

Simple loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Reverse loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Two at a time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Looping through elements in an array . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Applying an operation to all the elements in an array . . . . . . . . . . . . . . . . 155
Searching an array for a specific value . . . . . . . . . . . . . . . . . . . . . . . . . 156
Cross-indexing a pair of arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Hangman . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Book project: Creating the static graphics . . . . . . . . . . . . . . . . . . . . . . . . . 172
Setting up the timeline layers for your graphics . . . . . . . . . . . . . . . . . . . . 174
Creating the back strip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Adding structure to the Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Creating the frame cutout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Revealing the frame cutout and finishing the FLA . . . . . . . . . . . . . . . . . . . 180
Parting shots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Chapter 6 Movies That Remember How to Do Things . . . . . . . . . . 185
Breaking down a task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Bundling actions and running them afterward . . . . . . . . . . . . . . . . . . . . . . . 187
Using anonymous and named functions . . . . . . . . . . . . . . . . . . . . . . . . 187
Using functions to hide evil math . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Using functions to take care of repetitive jobs . . . . . . . . . . . . . . . . . . . . . 191
Choosing which actions to bundle and where . . . . . . . . . . . . . . . . . . . . . . . 192
Arguments and redundancy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
Local variables and modular code . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Returning values from a function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
Typing functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Running in circles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
Nesting functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Using nested functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

Using more function nesting to tidy up your script . . . . . . . . . . . . . . . . . . 210
Book project: Creating the dynamic graphics . . . . . . . . . . . . . . . . . . . . . . . . 213
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
CONTENTS
vii
6188FM.qxd 3/8/06 12:48 PM Page vii
Chapter 7 Objects and Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
Introducing objects and classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
Type and object-oriented programming . . . . . . . . . . . . . . . . . . . . . . . . 224
Classes, generalization, and abstraction . . . . . . . . . . . . . . . . . . . . . . . . . 224
Seeing arrays in a new light . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
The Array constructor method . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Other Array methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
Array properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
Creating classes and objects (instances) in Flash . . . . . . . . . . . . . . . . . . . . . . 229
Instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
The Object object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
Viewing an object in Flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Objects, objects, everywhere . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Lurking objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Making a show reel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
Book project: Initializing the code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
Getting yourself comfortable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Initializing the site variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Telling ActionScript about the stage . . . . . . . . . . . . . . . . . . . . . . . . . . 260
Sanity check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
Setting up your tricolor colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
Sanity check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
Final words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
Chapter 8 Objects on the Stage . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Movie clips and buttons as objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
Symbol types and behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
Two sides of the same object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
Working with Library items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
Let chaos reign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Bitmap caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
The other side of bitmap caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
Bitmap caching and RAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
Changing the appearance of a cached movie clip . . . . . . . . . . . . . . . . . . . 285
When to use bitmap caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Referencing different timelines with ActionScript . . . . . . . . . . . . . . . . . . . . . 287
Different place, different variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Locating variables from inside an event handler function . . . . . . . . . . . . 288
Reusing handler functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
The apply method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Global variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
CONTENTS
viii
6188FM.qxd 3/8/06 12:48 PM Page viii
74c27830997b0236f48fc25d2b37ea47
Chapter 9 Reusable Code and Realistic Movement . . . . . . . . . . . . 299
Breaking down big tasks into smaller ones . . . . . . . . . . . . . . . . . . . . . . . . . 300
Black-box programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
Creating simple components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
Creating a modular set of playback controls . . . . . . . . . . . . . . . . . . . . . . 303
Dark Valentine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
Modular control of movie clips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314

How to simulate realistic movement . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Motion with acceleration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
Trailing the pointer (a mouse follower) . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
Understanding the inertial code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Fine-tuning the component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Function-based modular code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
Swarming behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
Taking the swarming effect forward . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
Creating tweens with ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
Using import to access the Tween class . . . . . . . . . . . . . . . . . . . . . . . . . 333
How to use the Tween constructor function . . . . . . . . . . . . . . . . . . . . . . 334
Understanding the transition types . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
Book project: Setting up the color transition . . . . . . . . . . . . . . . . . . . . . . . . 338
Making it modular . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
Sanity check #1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
Sanity check #2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
Running the FLA: The results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Parting shots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Chapter 10 Games and Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
What is a sprite? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
External and internal data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Collision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Planning zapper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
The game world (the main timeline) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
gSCREEN_TOP, gSCREEN_BOTTOM, gSCREEN_RIGHT, and gSCREEN_LEFT . . . . . 368
score . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
level, skill, and accel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368

speed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
shipDead, fired, and gSHIP_HEIGHT . . . . . . . . . . . . . . . . . . . . . . . . . . 368
The timeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
CONTENTS
ix
6188FM.qxd 3/8/06 12:48 PM Page ix
The code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
Global constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
The “start game” trigger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
The player (the ship) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
The SwarmAlien . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
alienSpawn() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
onEnterFrame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
alienBrain() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
alienReincarnate() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
The SwarmAlien code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
The bullet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
The debris of war . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
Book project: Navigation event handling . . . . . . . . . . . . . . . . . . . . . . . . . . 390
Sanity check #1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
Adding the basic UI animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
navigate() and posTransition() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
Adding typing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
Sanity check #2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
Creating a smooth transition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
Parting shots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
Chapter 11 Drawing API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
Turtle graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
Drawing lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411

Drawing curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
How the sketching code works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
Filling shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
Creating a kaleidoscope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
Kaleidoscope math . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
Building the kaleidoscope engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Book project: Color transition event handling and data . . . . . . . . . . . . . . . . . . 435
Wiring the colTransition() function . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
The game plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
Fading color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
Coding the color transition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
Finishing the text transition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
Reviewing the code so far . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
Data-driven sites (and why you need to understand them) . . . . . . . . . . . . . . 442
Defining data for Futuremedia . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
Parting shots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
CONTENTS
x
6188FM.qxd 3/8/06 12:48 PM Page x
Chapter 12 Adding Sound to Flash . . . . . . . . . . . . . . . . . . . . . . . . . 453
Choosing the right sound format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
Using sound on a timeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
Using the ActionScript Sound class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458
Playing sounds from ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458
Attaching sounds to a sound instance . . . . . . . . . . . . . . . . . . . . . . . 458
Starting and stopping sounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462
Creating dynamic soundtracks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
Using ActionScript to control volume and balance . . . . . . . . . . . . . . . . 469
Dealing with large sound files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476

Using compression to reduce download times . . . . . . . . . . . . . . . . . . . . . 476
Loading sound from external files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478
Silence can also be golden . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485
Chapter 13 Loading Dynamic Data with XML . . . . . . . . . . . . . . . . . 487
XML 101 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488
How an XML document is structured . . . . . . . . . . . . . . . . . . . . . . . . . . 490
Using the right version and encoding . . . . . . . . . . . . . . . . . . . . . . . . . . 492
Using non-English text with XML in Flash . . . . . . . . . . . . . . . . . . . . . . 492
Saving XML files in UTF-8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494
How tags are used in XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496
Checking that your document is well formed . . . . . . . . . . . . . . . . . . . . . 496
Loading XML into Flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497
Book project: Controlling structure and content with XML . . . . . . . . . . . . . . . . 503
Building the basic XML structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503
Loading the XML data into Flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508
Creating the Futuremedia site’s data structure . . . . . . . . . . . . . . . . . . . . . 511
How the page array is structured . . . . . . . . . . . . . . . . . . . . . . . . . . 511
Populating the actual data values . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
Moving to the next level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517
Sanity check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
Chapter 14 Finishing the Futuremedia Case Study . . . . . . . . . . . . . 525
Getting the data into the user interface . . . . . . . . . . . . . . . . . . . . . . . . . . 526
Amending the way events are handled . . . . . . . . . . . . . . . . . . . . . . . . 530
Reading content pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
Adding the backward path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
Making sure the UI knows where it needs to return . . . . . . . . . . . . . . . . . . 533
How the buildIcon() function works . . . . . . . . . . . . . . . . . . . . . . . . 536
Tidying up the user interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540

A great big sanity check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
Adding the status text messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548
Adding a preloader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551
Loading your own content into the site . . . . . . . . . . . . . . . . . . . . . . . . 555
Parting shots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557
CONTENTS
xi
6188FM.qxd 3/8/06 12:48 PM Page xi
Chapter 15 Advanced ActionScript: Components and Classes . . . . 559
Flash version 2 components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560
Getting more out of components with ActionScript . . . . . . . . . . . . . . . . . . 563
Components and event handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
How event listeners work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
Adding an event listener . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569
Understanding the advantages of event listeners . . . . . . . . . . . . . . . . . 570
Commonly used components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
Radio buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
Check boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575
Combo boxes (drop-down menus) . . . . . . . . . . . . . . . . . . . . . . . . . 576
Using code hints with components . . . . . . . . . . . . . . . . . . . . . . . . . . . 583
Loading components at runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584
Removing components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586
Removing listeners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587
ActionScript and OOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587
The future road map for ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . 588
Is OOP for me? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589
How class-based coding works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
Extending classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597
Extending a built-in class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600

Storing classes in a central location . . . . . . . . . . . . . . . . . . . . . . . . . . . 602
Final thoughts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607
CONTENTS
xii
6188FM.qxd 3/8/06 12:48 PM Page xii
Kristian Besley is a Flash/web developer working in education and
specializing in interactivity and dynamically driven content using
ASP.NET and PHP. In his spare time, he is also a lecturer in multi-
media at the higher education level.
Kristian has written a number of friends of ED books, such as the
Foundation Flash series (including the recently published
Foundation Flash 8), Flash MX Video, and Learn Programming with
Flash MX. He was a contributor to the Flash Math Creativity books,
Flash MX 2004 Games Most Wanted, Flash MX Video Creativity, and
countless others. He also writes for Computer Arts magazine and has
produced freelance work for numerous clients, including the BBC.
Kristian currently resides in Swansea, Wales, the city of his birth. He is a fluent Welsh speaker and is
the creator of the first-ever Welsh translation search plug-in for Firefox and Mozilla (available from
).
Sham Bhangal has written on new media for friends of ED since the imprint’s inception. In that
time, he has been involved in the writing, production, and specification of just under 20 books.
Sham has considerable working experience with Macromedia and Adobe products, with a focus on
web design and motion graphics. Creating books that tell other people about his favorite subjects is
probably the best job he has had (ignoring the long hours, aggressive deadlines, lost manuscripts,
and occasional wiped hard drives). If he was doing something else, he’d probably be losing sleep
thinking about writing anyway.
Sham currently lives in the north of England with his longtime partner, Karen.
David Powers is a professional writer who has been involved in
electronic media for more than 30 years, first with BBC radio and

television, and more recently with the Internet. This is his sixth book
for Apress/friends of ED on programming for the Web. Among his
previous titles are the highly successful Foundation PHP 5 for Flash
(friends of ED, ISBN: 1-59059-466-5) and Foundation PHP for
Dreamweaver 8 (friends of ED, ISBN: 1-59059-569-6). David’s other
main area of expertise is Japan. He was a BBC correspondent in
Tokyo during the late 1980s and early 1990s, and later was Editor,
BBC Japanese TV. He has also translated several plays from Japanese.
xiii
ABOUT THE AUTHORS
Image courtesy of Simon James at
www.thefresh.co.uk
6188FM.qxd 3/8/06 12:48 PM Page xiii
6188FM.qxd 3/8/06 12:48 PM Page xiv
Corné van Dooren designed the front cover image for this book.
Having been given a brief by friends of ED to create a new design for
the Foundation series, he was inspired to create this new setup com-
bining technology and organic forms.
With a colorful background as an avid cartoonist, Corné discovered
the infinite world of multimedia at the age of 17—a journey of
discovery that hasn’t stopped since. His mantra has always been
“The only limit to multimedia is the imagination,” a philosophy that
is keeping him moving forward constantly.
After enjoying success after success over the past years—working for many international clients, as
well as being featured in multimedia magazines, testing software, and working on many other
friends of ED books—Corné decided it was time to take another step in his career by launching his
own company, Project 79, in March 2005.
You can see more of Corné’s work and contact him through www.cornevandooren.com or
www.project79.com. If you like his work, be sure to check out his chapter in New Masters of
Photoshop: Volume 2 (friends of ED, ISBN: 1-59059-315-4).

xv
ABOUT THE COVER IMAGE DESIGNER
6188FM.qxd 3/8/06 12:48 PM Page xv
6188FM.qxd 3/8/06 12:48 PM Page xvi
Welcome to Foundation ActionScript for Flash 8, the fourth edition of this legendary ActionScript
book.
ActionScript is, quite simply, the driving force behind Flash applications, allowing you to go beyond
simple tweened animations and give your movies intelligence, power, and class! The current version
of ActionScript in Flash 8, 2.0, is a fully featured, very powerful programming language.
But ActionScript is that scary code stuff that programmers do, right? Wrong. ActionScript adds
power and potential to your design work. It’s not going to turn you into a reclusive nerd who speaks
in 1s and 0s, and who only comes out after dark. It’s going to turn you into someone who finally has
the power to achieve his or her web design goals, rather than being hemmed in by frustrating
limitations.
And Flash 8 has a treasure trove of new features for you to play with. It has amazing new design fea-
tures such as filters and blend modes, features such as bitmap caching to enhance the speed of your
movies, exciting new video capabilities, a great new BitmapData API for manipulating images on the
fly, and much more.
If you know nothing or little about ActionScript, this book will provide you with a real foundation of
knowledge from which you can build some awe-inspiring structures. You’ll learn all the important
stuff you’ll need to make that giant leap toward becoming an ActionScript guru.
What you need to know
You’ve picked up this book, so we guess that you have the Flash basics under your belt. You’ll prob-
ably have built some basic timeline-based movies with tweens and so on, and you may have read an
introductory Flash book such as friends of ED’s acclaimed Foundation Flash 8. If you haven’t, we do
recommend looking at it; you can find it at www.friendsofed.com.
If you don’t have a copy of Flash 8 yet, you can download a fully functional 30-day free trial from
www.macromedia.com. You can use either the Basic or Professional edition of Flash with this book,
but we highly recommend going for Professional, as it features even more amazing functionality
than the Basic edition!

xvii
INTRODUCTION
6188FM.qxd 3/8/06 12:48 PM Page xvii
FLAs for download
There’s a wealth of code and support files available for this book. They’re organized by chap-
ter at the Foundation ActionScript for Flash 8 page at www.friendsofed.com. Look under the
book option on the site’s main navigation to find it, and feel free to look around the site in
general!
The case study: Futuremedia
Throughout the course of this book you’ll create a website called Futuremedia from scratch.
You can access a fully functioning version of the website you’ll be building as you progress
through this book at the URL you’ll find on the downloads page (or you can go to
www.futuremedia.org.uk for the latest incarnation).
Centering the Futuremedia site in the browser
When you publish the Futuremedia site, you should use the following settings in the File ➤
Publish Settings ➤ HTML tab:
INTRODUCTION
xviii
6188FM.qxd 3/8/06 12:48 PM Page xviii
With these settings, you’ll see something like this in the browser (press F12 to publish the site
and view it in your browser):
INTRODUCTION
xix
6188FM.qxd 3/8/06 12:48 PM Page xix
That’s fine, but most professional sites center the Flash site in the browser, so it looks some-
thing like this instead:
There’s no direct way of achieving this in Flash—you have to edit the HTML. To do this, find
the HTML file created by Flash (it will be in the same folder as the FLA), and open it in a text
editor such as Notepad. You’ll see something like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ➥

" /><html xmlns= xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;➥
charset=iso-8859-1" />
<title>index</title>
</head>
<body bgcolor="#666666">
<! urls used in the movie >
<! text used in the movie >
<!
futuremedia
future work
media people
loading:
this is a skip-intro free site
>
INTRODUCTION
xx
6188FM.qxd 3/8/06 12:48 PM Page xx
<object classid="clsid:d27cdb6e-ae6d-➥
11cf-96b8-444553540000" codebase=➥
" />shockwave/cabs/flash/swflash.cab#➥
version=8,0,0,0" width="800" height=➥
"600" id="index" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="index.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#666666" />
<embed src="index.swf" quality="high"➥
bgcolor="#666666" width="800" height=➥

"600" name="index" align="middle"➥
allowScriptAccess="sameDomain" type=➥
"application/x-shockwave-flash"➥
pluginspage=" />go/getflashplayer" />
</object>
</body>
</html>
This is XHTML, so you should really play ball and use CSS and <div> and <span>, and no HTML
tables or table horizontal and vertical centering (not least because vertical centering of a table
doesn’t work in XHTML!). Add the following lines to create a CSS-based centered-in-browser
page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ➥
" /><html xmlns= xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;➥
charset=iso-8859-1" />
<title>index</title>
<style type="text/css">
<!
body
{
margin: 0px;
background-color:#666666;
}
#centercontent
{
text-align: center;
margin-top: -300px;
margin-left: -400px;
position: absolute;

top: 50%;
left: 50%;
}
INTRODUCTION
xxi
6188FM.qxd 3/8/06 12:48 PM Page xxi
>
</style>
</head>
<body>
<! urls used in the movie >
<! text used in the movie >
<!
futuremedia
future work
media people
loading:
this is a skip-intro free site
>
<div id="centercontent">
<object classid="clsid:d27cdb6e-ae6d-➥
11cf-96b8-444553540000" codebase=➥
" />shockwave/cabs/flash/swflash.cab#➥
version=8,0,0,0" width="800" height=➥
"600" id="index" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="index.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#666666" />
<embed src="index.swf" quality="high"➥

bgcolor="#666666" width="800" height=➥
"600" name="index" align="middle"➥
allowScriptAccess="sameDomain" type=➥
"application/x-shockwave-flash"➥
pluginspage=" />go/getflashplayer" />
</object>
</div>
</body>
</html>
Note also that the deprecated bgcolor attribute has been removed from the <body> element
and replaced with a nice shiny new standards-compliant CSS rule.
INTRODUCTION
xxii
6188FM.qxd 3/8/06 12:48 PM Page xxii
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.
Pseudo-code and variable input are written in
italic fixed-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:
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.
PCs and Macs
To make sure this book is as useful to you as possible, we’ve tried to avoid making too many

assumptions about whether you’re running Flash on a PC or a Mac. However, when it comes to
mouse clicks and modifier buttons, we can’t generalize. There’s no two ways about it: they’re
different!
When we use the term “click,” we mean left-click on the PC or simply click on the Mac. On the
other hand, a right-click on the PC corresponds to holding down the Ctrl button and clicking
on the Mac. This is abbreviated as Ctrl-click.
Another important key combination on the PC is when you hold down the Ctrl key while you
press another key (or click something). This sort of thing is abbreviated as Ctrl-click. The Mac
equivalent is to hold down the Cmd key (also known as the “apple” or “flower” key) instead,
so you’ll normally see this written out in the form Ctrl+C/Cmd+C, or Ctrl+V/Cmd+V, for
example.
OK, now that we’ve taken care of the preliminaries, let’s get to work!
Ahem, don’t say we didn’t warn you.
INTRODUCTION
xxiii
6188FM.qxd 3/8/06 12:48 PM Page xxiii
6188CH01.qxd 3/8/06 12:50 PM Page xxiv

×