Phillip Kerman
Macromedia®
Flash 8 ®
@work
PROJECTS AND TECHNIQUES TO GET THE JOB DONE
800 East 96th Street, Indianapolis, Indiana 46240
Macromedia Flash 8 @work: Projects You Can Use Acquisitions Editor
Linda Bump Harrison
on the Job
Development Editor
Copyright 2006 by Phillip Kerman Alice Martina Smith
All rights reserved. No part of this book shall be reproduced, stored in a retrieval
Managing Editor
system, or transmitted by any means, electronic, mechanical, photocopying,
recording, or otherwise, without written permission from the publisher. No Charlotte Clapp
patent liability is assumed with respect to the use of the information contained
herein. Although every precaution has been taken in the preparation of this Project Editor
book, the publisher and author assume no responsibility for errors or omissions. Dan Knott
Nor is any liability assumed for damages resulting from the use of the informa-
tion contained herein. Production Editor
International Standard Book Number: 0-672-32828-3 Megan Wade
Library of Congress Catalog Card Number: 2005903522 Indexer
Printed in the United States of America Erika Millen
First Printing: January 2006
Proofreader
09 08 07 06 4 3 2 1
Brad Engels
Trademarks Technical Editors
All terms mentioned in this book that are known to be trademarks or service
marks have been appropriately capitalized. Sams Publishing cannot attest to the
Aria Danika
accuracy of this information. Use of a term in this book should not be regarded Larry Drolet
as affecting the validity of any trademark or service mark. David Vogeleer
Warning and Disclaimer Publishing Coordinator
Every effort has been made to make this book as complete and as accurate as Vanessa Evans
possible, but no warranty or fitness is implied. The information provided is on
an “as is” basis. The author and the publisher shall have neither liability nor Multimedia Developer
responsibility to any person or entity with respect to any loss or damages arising Dan Scherf
from the information contained in this book or from the use of the programs
accompanying it. Book Designer
Bulk Sales Gary Adair
Sams Publishing offers excellent discounts on this book when ordered in quan- Page Layout
tity for bulk purchases or special sales. For more information, please contact
Michelle Mitchell
U.S. Corporate and Government Sales
1-800-382-3419
[email protected]
For sales outside the United States, please contact
International Sales
[email protected]
Snowboard image courtesy of www.deepplay.com/sites/m399/.
Contents at a Glance
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Part I: Getting Started
1 Exploring Flash 8 ........................9
2 Producing a Flash Project . . . . . . . . . . . . . . . . 29
Part II: Projects
3 Creating a Video with Synchronized
Captions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
4 Creating a Portfolio. . . . . . . . . . . . . . . . . . . . . . 97
5 Creating an Assessment Quiz . . . . . . . . . . . . 149
6 Saving and Evaluating Quiz Results. . . . . . . 187
7 Creating a PowerPoint-style Slide
Presentation . . . . . . . . . . . . . . . . . . . . . . . . . . 217
8 Creating a CD-ROM Front End . . . . . . . . . . . . 249
9 Creating Special Effects . . . . . . . . . . . . . . . . . 287
10 Building a Photo Share Application . . . . . . . 325
Part III: Appendixes
A Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
B Components . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
Table of Contents Authortime Versus Runtime . . . . . . . . . . 44
An ActionScript 2 Primer. . . . . . . . . . . . . 45
Typing Variables . . . . . . . . . . . . . . . 46
Flash’s Classpath . . . . . . . . . . . . . . . 46
Introduction 1 The Import Statement and
Namespaces . . . . . . . . . . . . . . . . . . 48
Part I: Getting Started Sample Project Template . . . . . . . . . . . . . 50
Planning for the End Product
1 Exploring Flash 8 9 First . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
What’s New in Flash 8 ................9
Building a Template . . . . . . . . . . . 53
Expressive Features . . . . . . . . . . . . . . 9 Understanding Other Project
Variations . . . . . . . . . . . . . . . . . . . . . 55
Video Improvements . . . . . . . . . . . 12
Final Thoughts . . . . . . . . . . . . . . . . . . . . . . . 57
Workflow Improvements . . . . . . . 13
Flash Player . . . . . . . . . . . . . . . . . . . . 15
Part II: Projects
Flash Professional 8 and Flash
Basic 8 . . . . . . . . . . . . . . . . . . . . . . . . 17
ActionScript Additions . . . . . . . . . . . . . . . 17 3 Creating a Video with Synchronized
Captions 61
A Programming Primer . . . . . . . . 17
About the Projects . . . . . . . . . . . . . . . . . . . . 61
The flash.filters Package . . . . . . . 21
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . 61
The flash.display.BitmapData
Class . . . . . . . . . . . . . . . . . . . . . . . . . . 22 @work resources . . . . . . . . . . . . . . . . 61
The flash.geom Package . . . . . . . 22 Planning the Projects . . . . . . . . . . . . . . . . 62
The Cue Points and Captions . . . . . . . 62
flash.external.ExternalInterface Cue Point Types . . . . . . . . . . . . . . . . 62
Class . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Embedded Cue Points Versus
The flash.net Package . . . . . . . . . . 26 Separate Text Files . . . . . . . . . . . . 64
Final Thoughts . . . . . . . . . . . . . . . . . . . . . . . 27 Project: Navigation Cue Points in a
.flv File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
2 Producing a Flash Project 29 Creating a New .fla File . . . . . . . . 66
Flash’s File Structure . . . . . . . . . . . . . . . . . 29 Importing the Source Video . . . . 66
Timeline Animation . . . . . . . . . . . 30 Choosing Video Options . . . . . . . 66
Movie Clip Hierarchy . . . . . . . . . . 32 Adding the First Navigation
Selecting. . . . . . . . . . . . . . . . . . . . . . . . 34 Cue Point . . . . . . . . . . . . . . . . . . . . . 67
Modular Delivery . . . . . . . . . . . . . . 36 Adding More Navigation Cue
Points . . . . . . . . . . . . . . . . . . . . . . . . . 69
ActionScript . . . . . . . . . . . . . . . . . . . . 39
Skinning the Video . . . . . . . . . . . . . 69
Library Items . . . . . . . . . . . . . . . . . . . 40
Navigating the Video . . . . . . . . . . 70
Disabling Export in First
Frame . . . . . . . . . . . . . . . . . . . . . . . . . 41
iv Macromedia Flash 8 @work: Projects You Can Use on the Job
Project: ActionScript Cue Points for Project: Advanced Captioning
Captions in an XML File. . . . . . . . . . . . 70 Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Preparing to Use the Offline Creating the captionType2.fla
Gathering Tool. . . . . . . . . . . . . . . . 70 File . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Loading the Video and Transcript Nesting the Text in a Clip . . . . . . 84
into the Gathering Tool. . . . . . . 71 Modifying the Code to Move
Setting Cue Points While the the Text . . . . . . . . . . . . . . . . . . . . . . . 85
Video Plays . . . . . . . . . . . . . . . . . . . 71 Publishing and Testing . . . . . . . . . 86
Exporting the XML File . . . . . . . . 72 Adding Code for the
Project: Basic Caption Display Hide/Reveal Feature . . . . . . . . . . 87
Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Creating the Hide/Reveal
Creating a captionType1.fla Button . . . . . . . . . . . . . . . . . . . . . . . . 88
File . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Project: Synchronized Images
Adding the Minimum Code . . . . 74 Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Creating the .swf File. . . . . . . . . . . 75 Encoding the Video . . . . . . . . . . . . 89
Project: Channeling Cue Points to the Preparing to Gather Cue
Caption Display . . . . . . . . . . . . . . . . . . . . 75 Points . . . . . . . . . . . . . . . . . . . . . . . . . 89
Creating the main.fla File. . . . . . 76 Creating an Animated
Creating the CaptionHolder Sequence . . . . . . . . . . . . . . . . . . . . . . 89
Symbol . . . . . . . . . . . . . . . . . . . . . . . 76 Gathering the Cue Points . . . . . . 90
Assembling Support Class Implementing the ActionScript
Files . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 in imagesTemplate.fla . . . . . . . . 92
Implementing the Final Code . . 78 Entering the ActionScript in
Alternative 1: Making the Video main_coffee.fla . . . . . . . . . . . . . . . 92
Play Automatically . . . . . . . . . . . 79 Testing main_coffee.fla. . . . . . . . . 94
Alternative 2: Adding a Second Exploring the Support Classes . . . . . . . 94
captionText1.swf That Supports Final Thoughts . . . . . . . . . . . . . . . . . . . . . . . 96
Navigation Cue Points . . . . . . . 79
Project: Code for Audio-only 4 Creating a Portfolio 97
Captions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
About the Project. . . . . . . . . . . . . . . . . . . . . 97
Capturing the Cue Points . . . . . . 80
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Creating the main_audio.fla
@work resources . . . . . . . . . . . . . . . . 97
File . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Planning the Projects . . . . . . . . . . . . . . . . 98
Assembling Support Files . . . . . . 81
Media Selection . . . . . . . . . . . . . . . . 98
Writing the Code . . . . . . . . . . . . . . . 81
Internal Versus External . . . . . . . 99
Alternative: Using the
MediaPlayback Stage Layout . . . . . . . . . . . . . . . . . . 100
Component . . . . . . . . . . . . . . . . . . . 82 Communication Gateways . . . 101
Contents v
Project: Media Preparation . . . . . . . . . 102 Project: Alternative Chapter
Resizing Images . . . . . . . . . . . . . . . 102 Templates . . . . . . . . . . . . . . . . . . . . . . . . . 124
Preparing the Thumbnails . . . . 102 Creating the
chapters_hardwired.fla File. . 124
Tagging the Images . . . . . . . . . . . 103
Writing the Code for
Project: Main Framework and
chapters_hardwired.fla . . . . . . 124
Minimum Support Templates . . . . . 104
Modifying the Main File to Run
Creating the Main File . . . . . . . . 105
chapters_hardwired.swf . . . . . 126
Creating a Holder for the
Creating the
ProgressBar Clip . . . . . . . . . . . . . 105
chapters_homemade.fla
Entering Image Information . . 105 File . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Entering Template Writing the Code for
Information . . . . . . . . . . . . . . . . . 107 chapters_homemade.fla . . . . . 127
Instantiating the Modifying the Main File to Run
PhotoController . . . . . . . . . . . . . 107 chapters_homemade.swf . . . . 129
Creating a Simple Display Project: Advanced Thumbnail
Template . . . . . . . . . . . . . . . . . . . . 108 Templates . . . . . . . . . . . . . . . . . . . . . . . . . 130
Creating a Simple Thumbnails Creating the Clip-based
Template . . . . . . . . . . . . . . . . . . . . 109 Horizontal Thumbnail
Coding the Thumbnails Template . . . . . . . . . . . . . . . . . . . . 131
Template . . . . . . . . . . . . . . . . . . . . 111 Entering the Code for
Testing It . . . . . . . . . . . . . . . . . . . . . . 113 thumbnailsH_clip.fla . . . . . . . . 132
Creating the Simple Chapters Using main_tester_app.swf to
Template . . . . . . . . . . . . . . . . . . . . 113 Test Your Template . . . . . . . . . . 136
Including the Chapters Creating the
Template and Testing . . . . . . . 115 thumbnailsH_linkage.fla
Project: Advanced Display Template . . . . . . . . . . . . . . . . . . . . 137
Templates . . . . . . . . . . . . . . . . . . . . . . . . . 116 Modifying the Code for the
Creating the display_slide.fla thumbnailsH_linkage.fla
File . . . . . . . . . . . . . . . . . . . . . . . . . . 116 File . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Writing the Code for Creating the
display_slide.fla . . . . . . . . . . . . . 117 thumbnailsH_import.fla
Template . . . . . . . . . . . . . . . . . . . . 139
Modifying the Main File to
Run display_slide.swf . . . . . . . . 119 Entering the Code for
thumbnailsH_import.fla . . . . 139
Creating the display_fade.fla
File . . . . . . . . . . . . . . . . . . . . . . . . . . 120 Creating Vertical Thumbnail
Templates . . . . . . . . . . . . . . . . . . . 140
Writing the Code for
display_fade.fla . . . . . . . . . . . . . 120 Project: Externalized Image
Information . . . . . . . . . . . . . . . . . . . . . . . 141
Modifying the Main File to
Run display_fade.swf . . . . . . . . 123 Creating and Populating the
images.xml File . . . . . . . . . . . . . 141
vi Macromedia Flash 8 @work: Projects You Can Use on the Job
Creating the main_external.fla Laying Out the Stage . . . . . . . . . 163
File . . . . . . . . . . . . . . . . . . . . . . . . . . 142 Adding the RadioButton
Coding the main_external.fla Component. . . . . . . . . . . . . . . . . . 163
File . . . . . . . . . . . . . . . . . . . . . . . . . . 143 Changing the ActionScript . . . 163
Exploring the Class Structure . . . . . . . 145 Testing the multipleChoiceSingle
Final Thoughts . . . . . . . . . . . . . . . . . . . . . . 146 Template . . . . . . . . . . . . . . . . . . . . 166
Project: Multiple-Choice/Multiple
5 Creating an Assessment Quiz 149 Answer Template . . . . . . . . . . . . . . . . . . 167
About the Project . . . . . . . . . . . . . . . . . . . 149 Creating the
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . 149
multipleChoiceMultiple.fla
File . . . . . . . . . . . . . . . . . . . . . . . . . . 167
@work resources . . . . . . . . . . . . . . 149
Laying Out the Stage . . . . . . . . . 167
Planning the Projects . . . . . . . . . . . . . . . 150
Adding the CheckBox
Writing Effective Questions . . . 150
Component. . . . . . . . . . . . . . . . . . 168
Designing Question
Changing the ActionScript . . . 168
Templates . . . . . . . . . . . . . . . . . . . 151
Testing the
Client-side Versus
multipleChoiceMultiple
Server-side . . . . . . . . . . . . . . . . . . . 153
Template . . . . . . . . . . . . . . . . . . . . 170
Planning for Extensibility . . . . . 153
Project: A Hotspot Template . . . . . . . 170
Project: Quiz Content . . . . . . . . . . . . . . 154
Creating the hotSpot.fla File . . 171
Studying the XML Format . . . . 155
Laying Out the Stage . . . . . . . . . 171
Writing Sample Content for
Modifying the File’s
multipleChoiceSingle . . . . . . . . 155
Contents . . . . . . . . . . . . . . . . . . . . . 171
Writing Sample Content for
Changing the ActionScript . . . 173
multipleChoiceMultiple . . . . . 156
Testing the hotSpot
Writing Sample Content for
Template . . . . . . . . . . . . . . . . . . . . 176
hotSpot . . . . . . . . . . . . . . . . . . . . . . 157
Project: Drag-and-Drop Template . . 177
Writing Sample Content for
dragAndDrop . . . . . . . . . . . . . . . 157 Creating the dragAndDrop.fla
File . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Project: Starter Template . . . . . . . . . . . 158
Laying Out the Stage . . . . . . . . . 177
Creating the Starter File . . . . . . 159
Changing the ActionScript . . . 177
Placing Text on the Stage . . . . . 159
Testing the dragAndDrop
Entering Skeleton Code . . . . . . . 159
Template . . . . . . . . . . . . . . . . . . . . 179
Publishing . . . . . . . . . . . . . . . . . . . . 161
Project: Results Template . . . . . . . . . . . 179
Modifying the quiz.xml File . . 161
Creating the results.fla File . . . 180
Testing the Quiz Engine. . . . . . . 162
Laying Out the Stage . . . . . . . . . 180
Project: Multiple-Choice/Single
Building a Simple Results
Answer Template . . . . . . . . . . . . . . . . . . 163
Template . . . . . . . . . . . . . . . . . . . . 180
Creating the
Testing the Simple Results
multipleChoiceSingle.fla
Template . . . . . . . . . . . . . . . . . . . . 181
File . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Contents vii
Building an Advanced Results Project: Advanced All-Flash
Page . . . . . . . . . . . . . . . . . . . . . . . . . 182 Login . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
Testing the Advanced Results Creating the
Page . . . . . . . . . . . . . . . . . . . . . . . . . 184 login_advanced.fla File . . . . . 203
Exploring the Class Structure . . . . . . . 184 Adding Methods to the
Final Thoughts . . . . . . . . . . . . . . . . . . . . . . 185 urls.xml File . . . . . . . . . . . . . . . . . 203
Creating Static XML Files in
6 Saving and Evaluating Quiz Results 187 Lieu of Live Server-side
Methods . . . . . . . . . . . . . . . . . . . . . 204
About the Projects . . . . . . . . . . . . . . . . . . 187
Creating the
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . 187
login_advanced_html.html File
@work resources . . . . . . . . . . . . . . 187 and Adding the FlashVars . . . 205
Planning the Projects . . . . . . . . . . . . . . . 188 Applying the ActionScript . . . . 206
Benefits of Application Project: APIs for the Admin
Servers . . . . . . . . . . . . . . . . . . . . . . . 188 Assessment Tool . . . . . . . . . . . . . . . . . . . 207
Keeping Login Separate . . . . . . . 188 Defining How to Get Quiz
Login Options. . . . . . . . . . . . . . . . . 189 Data . . . . . . . . . . . . . . . . . . . . . . . . . 208
Ascertaining Variable Values Defining How Quiz Results
from Inside quiz.swf . . . . . . . . . 189 Are Saved . . . . . . . . . . . . . . . . . . . 209
Chapter Projects . . . . . . . . . . . . . . 190 Defining How Users Can Log
Project: External Paths to In . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Server-side Methods . . . . . . . . . . . . . . . 192 Providing a Way to Retrieve
Adding Methods to the All the quizIDs . . . . . . . . . . . . . . 210
urls.xml File . . . . . . . . . . . . . . . . . 192 Defining an API to Retrieve
Specifying the Location of the All userIDs . . . . . . . . . . . . . . . . . . 210
urls.xml File . . . . . . . . . . . . . . . . . 193 Defining an API to Retrieve
Project: Traditional Login . . . . . . . . . . 194 All quizIDs for One userID . . 211
Adding FlashVars to Defining an API to Retrieve
quiz.html . . . . . . . . . . . . . . . . . . . . 195 All Scores for a Quiz . . . . . . . . . 211
Adding the debug Switch in Defining an API to Retrieve
quiz.fla . . . . . . . . . . . . . . . . . . . . . . 195 Detailed Quiz Results . . . . . . . . 212
Testing It . . . . . . . . . . . . . . . . . . . . . . 197 Project: API Tester . . . . . . . . . . . . . . . . . . 213
Project: Simple All-Flash Login. . . . . 198 Project: Simple Admin Tool . . . . . . . . 214
Creating the login_simple.fla Using the Full-featured Admin
File . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Coding It . . . . . . . . . . . . . . . . . . . . . . 199 Final Thoughts . . . . . . . . . . . . . . . . . . . . . . 216
Creating the
quiz_html_simple.html
File . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Publishing and Testing . . . . . . . 200
viii Macromedia Flash 8 @work: Projects You Can Use on the Job
7 Creating a PowerPoint-style Slide Embedding the Fonts . . . . . . . . . 234
Presentation 217 Writing the Code for the
About the Projects . . . . . . . . . . . . . . . . . . 217 pullquote.swf Template. . . . . . 235
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . 217 Project: Bullet List Template. . . . . . . . 238
@work resources . . . . . . . . . . . . . . 217 Designing the XML
Structure . . . . . . . . . . . . . . . . . . . . . 238
Planning the Projects . . . . . . . . . . . . . . . 218
Adding the Styles to the CSS
Understanding the Presentation
Document . . . . . . . . . . . . . . . . . . . 239
Features . . . . . . . . . . . . . . . . . . . . . 218
Embedding the Fonts . . . . . . . . . 239
Understanding the Template
Requirements . . . . . . . . . . . . . . . . 219 Writing the Template Code . . . 240
Formatting the Presentation Project: Slideshow Distribution . . . . . 244
Data . . . . . . . . . . . . . . . . . . . . . . . . . 220 Choosing Distribution
Designing Templates . . . . . . . . . . 221 Options . . . . . . . . . . . . . . . . . . . . . . 245
Effective Transitions. . . . . . . . . . . 222 Creating a Projector . . . . . . . . . . 245
Deployment Options . . . . . . . . . . 222 Collecting the Necessary
Distribution Files . . . . . . . . . . . . 245
The Point of a Presentation . . . 222
Exploring the Support Classes . . . . . . 246
Project: Simple Photo Caption
Template . . . . . . . . . . . . . . . . . . . . . . . . . . 223 Final Thoughts . . . . . . . . . . . . . . . . . . . . . . 247
Setting Up the Document . . . . . 223
Laying Out the Photo
8 Creating a CD-ROM Front End 249
Holder . . . . . . . . . . . . . . . . . . . . . . . 223 About the Project . . . . . . . . . . . . . . . . . . . 249
Laying Out the Caption Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . 249
Text . . . . . . . . . . . . . . . . . . . . . . . . . . 223 @work resources . . . . . . . . . . . . . . 249
Adding the Customized Planning the Projects . . . . . . . . . . . . . . . 250
ActionScript . . . . . . . . . . . . . . . . . 224
Why Not Create a Flash
Editing the XML and Testing Projector? . . . . . . . . . . . . . . . . . . . . 250
the Template . . . . . . . . . . . . . . . . 226
Designing a Workable and
Project: Advanced Before-and-After Organized File Structure . . . . . 251
Photo Template. . . . . . . . . . . . . . . . . . . . 227
Making Custom Icons . . . . . . . . 252
Creating the Document and
Autorun . . . . . . . . . . . . . . . . . . . . . . . 252
Layout . . . . . . . . . . . . . . . . . . . . . . . 227
Full Screen, Title Bars, and
Writing the Code to Support
Quitting . . . . . . . . . . . . . . . . . . . . . 253
Stepping . . . . . . . . . . . . . . . . . . . . . 227
Decoupling the Front End, Data,
Writing the XML for This
and System-level Calls . . . . . . 254
Template . . . . . . . . . . . . . . . . . . . . 231
Pieces You’ll Build in This
Project: CSS Support in a Pull Quote
Chapter . . . . . . . . . . . . . . . . . . . . . 254
Template . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Creating the CSS Styles . . . . . . . 233
Designing the Slide Node . . . . . 233
Contents ix
Project: XML Document That Adding Code to Respond to
Identifies All Files . . . . . . . . . . . . . . . . . 255 User Events . . . . . . . . . . . . . . . . . . 277
Creating the Skeleton XML Project: Third-party Product
File . . . . . . . . . . . . . . . . . . . . . . . . . . 255 Integration . . . . . . . . . . . . . . . . . . . . . . . . 279
Adding and Modifying the Copying the Support Files . . . . 280
Item.as Class . . . . . . . . . . . . . . . . 256 Instantiating the ThirdParty.as
Adding and Modifying the Class. . . . . . . . . . . . . . . . . . . . . . . . . 280
Section.as Class . . . . . . . . . . . . . 258 Triggering the ThirdParty Class’s
Copying the Data Folders . . . . . 259 openFile() and doSaveAs()
Project: The main.fla File . . . . . . . . . . 259 Methods . . . . . . . . . . . . . . . . . . . . . 281
Adding the SectionMaker.as Project: Stub Application . . . . . . . . . . . 282
and utils.as Class Files . . . . . . 259 Preparing the File Structure . . . 283
Creating the main.fla File . . . . 260 Creating the stub.fla File . . . . . 283
Writing the Code . . . . . . . . . . . . . 260 Building the Projector . . . . . . . . . 283
Project: Section Templates. . . . . . . . . . 262 Project: Auto-play Functionality . . . 284
Assembling the section_simple.fla Creating the autorun.inf
File . . . . . . . . . . . . . . . . . . . . . . . . . . 263 File . . . . . . . . . . . . . . . . . . . . . . . . . . 284
Writing the Code . . . . . . . . . . . . . 264 Copying the Files . . . . . . . . . . . . . 284
Testing the Simple Exploring the Class Structure . . . . . . . 285
Template . . . . . . . . . . . . . . . . . . . . 267 Final Thoughts . . . . . . . . . . . . . . . . . . . . . . 286
Creating the
section_animated.swf 9 Creating Special Effects 287
Template . . . . . . . . . . . . . . . . . . . . 268
About the Project . . . . . . . . . . . . . . . . . . . 287
Modifying the Code in
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . 287
section_animated.fla . . . . . . . . 269
@work resources . . . . . . . . . . . . . . 287
Modifying main.fla to Point to
section_animate.swf . . . . . . . . . 270 Planning the Projects . . . . . . . . . . . . . . . 288
Designing the section_static.swf Think About Impressions, Not
Template . . . . . . . . . . . . . . . . . . . . 271 Effects . . . . . . . . . . . . . . . . . . . . . . . 288
Building the section_static.swf Start with the End in Mind . . . 288
Template . . . . . . . . . . . . . . . . . . . . 271 Timeline Versus Scripted
Writing the Code for the Effects . . . . . . . . . . . . . . . . . . . . . . . 288
section_static.fla File . . . . . . . . 273 Justify Everything . . . . . . . . . . . . . 289
Modifying main.fla to Point to Project: Continuous Loop . . . . . . . . . . 289
section_static.swf . . . . . . . . . . . . 275 Creating One Cycle . . . . . . . . . . . 289
Project: Listeners in the main.fla Matching the End with the
File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
Beginning . . . . . . . . . . . . . . . . . . . 290
Adding User Interface Elements Making the Animation . . . . . . . 291
to main.fla . . . . . . . . . . . . . . . . . . 276
Touching Up the
Writing ActionScript That Animation. . . . . . . . . . . . . . . . . . . 292
Listens for User Events . . . . . . . 277
x Macromedia Flash 8 @work: Projects You Can Use on the Job
Project: Jitter Effect . . . . . . . . . . . . . . . . . 293 Tracing While the Mouse Is
Drawing the Base Elements . . . 293 Down . . . . . . . . . . . . . . . . . . . . . . . . 306
Adding the Jitter . . . . . . . . . . . . . . 293 Making Tracers Appear in
Specific Parts of the
Project: Magnifier Lens Effect . . . . . . 294
Animation. . . . . . . . . . . . . . . . . . . 307
Creating the Large Movie
Project: VU Meter . . . . . . . . . . . . . . . . . . 307
Clip . . . . . . . . . . . . . . . . . . . . . . . . . . 294
Planning Your VU Meters . . . . . 308
Creating the Small Movie
Clip . . . . . . . . . . . . . . . . . . . . . . . . . . 295 Creating the Digital VU Meter
Symbol . . . . . . . . . . . . . . . . . . . . . . 308
Adding the Mask . . . . . . . . . . . . . 295
Copying the Support Files . . . . 309
Animating the Mask . . . . . . . . . . 296
Building a Test Bed
Adjusting the Motion . . . . . . . . . 296
Application . . . . . . . . . . . . . . . . . . 309
Adding a Layer for the
Entering Starter Code . . . . . . . . . 310
Reflection . . . . . . . . . . . . . . . . . . . . 296
Making an Analog Version . . . 312
Project: Blends and Filters . . . . . . . . . . 297
Project: DualFilter Classes . . . . . . . . . . 312
Using the Layer Blend for
Accurate Transparency . . . . . . 297 Selecting the Start and End
Filters . . . . . . . . . . . . . . . . . . . . . . . . 314
Making a Spotlight Effect Using
the Alpha Blend . . . . . . . . . . . . . 298 Creating Two Filter
Instances . . . . . . . . . . . . . . . . . . . . 314
Making a Black-and-White
Photo . . . . . . . . . . . . . . . . . . . . . . . . 299 Copying the Support Files . . . . 315
Making a Sepia-toned Photo . 299 Passing a Start and End BlurFilter
to the DualBlurFilter Class . . 315
Project: Matrixes for the
ColorMatrixFilter . . . . . . . . . . . . . . . . . . 300 Combining Filter Effects . . . . . . 316
Making a Photograph Black Using the WavyFilter Class . . . 316
and White Using Code . . . . . . 300 Project: Offline ListAnim Filter
Making a Photograph Sepia Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
Using Code . . . . . . . . . . . . . . . . . . 301 Creating the Offline
Project: Film Dirt . . . . . . . . . . . . . . . . . . . 301 Animation. . . . . . . . . . . . . . . . . . . 320
Copying the Required Files . . . 302 Copying the Support Files . . . . 320
Creating the Dirt. . . . . . . . . . . . . . 302 Running the FilterMonitor.as
Class to Gather the Filter
Entering Simple Code . . . . . . . . . 303
Values . . . . . . . . . . . . . . . . . . . . . . . 320
Setting Up a File to Put Dirt on
Creating the Online Version . . 321
a Video . . . . . . . . . . . . . . . . . . . . . . 304
Final Thoughts . . . . . . . . . . . . . . . . . . . . . . 322
Entering Code to Show Dirt
While Video Plays . . . . . . . . . . . 304
10 Building a Photo Share Application 325
Project: Tracers . . . . . . . . . . . . . . . . . . . . . 305
About the Project . . . . . . . . . . . . . . . . . . . 325
Creating an Animation . . . . . . . 305
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . 325
Copying the Support Files . . . . 306
@work resources . . . . . . . . . . . . . . 325
Contents xi
Planning the Projects . . . . . . . . . . . . . . . 326 Exploring the getImages.xml
Features for This Project . . . . . . 326 Schema . . . . . . . . . . . . . . . . . . . . . . 360
Additional Tags . . . . . . . . . . . . . . . 328 Creating the zoom_document_
version.swf File . . . . . . . . . . . . . . 360
Limits of the FileReference
Class. . . . . . . . . . . . . . . . . . . . . . . . . 329 Testing the PDF Download
Project . . . . . . . . . . . . . . . . . . . . . . . 363
Uploading and Downloading
from a Server Only . . . . . . . . . . 330 Project: List View for the Image
Filenames . . . . . . . . . . . . . . . . . . . . . . . . . 363
Project: Work Environment . . . . . . . . 331
Creating Another New Working
Setting Up the Static XML
Folder . . . . . . . . . . . . . . . . . . . . . . . . 364
Files . . . . . . . . . . . . . . . . . . . . . . . . . 331
Creating a New Thumbnail
Setting Up a Starter Folder of
Screen . . . . . . . . . . . . . . . . . . . . . . . 364
Images . . . . . . . . . . . . . . . . . . . . . . 332
Applying the ActionScript to
Copying the Support Files . . . . 333
the Thumbnail Screen . . . . . . . 365
Project: Basic Photo Share Project . . 333
Analyzing the ActionScript . . . 365
Creating the Main File . . . . . . . . 334
Creating a New Main File . . . . 367
Creating the selection.swf
Testing the Thumbnail List
Template . . . . . . . . . . . . . . . . . . . . 335
Screen . . . . . . . . . . . . . . . . . . . . . . . 367
Creating the upload.swf
Exploring the Class Structure . . . . . . . 368
Template . . . . . . . . . . . . . . . . . . . . 338
Final Thoughts . . . . . . . . . . . . . . . . . . . . . . 369
Assembling the thumbnail.swf
Template . . . . . . . . . . . . . . . . . . . . 341
Applying the Code for
Part III: Appendixes
thumbnail.swf . . . . . . . . . . . . . . . 343
Creating the zoom.swf A Resources 373
Template . . . . . . . . . . . . . . . . . . . . 347
Configuration Folders . . . . . . . . . . . . . . . 373
Creating the edit.swf
Macromedia Links . . . . . . . . . . . . . . . . . . 375
Template . . . . . . . . . . . . . . . . . . . . 351
Flash Uninstaller . . . . . . . . . . . . . . 375
Testing It . . . . . . . . . . . . . . . . . . . . . . 353
Player Archive . . . . . . . . . . . . . . . . 375
Project: No Upload and Editing
Features . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
Player Version. . . . . . . . . . . . . . . . . 375
Modifying the Selection LiveDocs . . . . . . . . . . . . . . . . . . . . . . 375
Screen . . . . . . . . . . . . . . . . . . . . . . . 356 Macromedia Labs . . . . . . . . . . . . . 376
Modifying the Zoom Screen . . 357 Community Sites . . . . . . . . . . . . . . . . . . . 376
Modifying the Main Screen . . . 357 Full as a Goog . . . . . . . . . . . . . . . . 376
Project: A Version That Downloads Community MX . . . . . . . . . . . . . . 376
.pdf Documents . . . . . . . . . . . . . . . . . . . 358 Chatty Fig. . . . . . . . . . . . . . . . . . . . . 376
Creating a New Working Open Source Flash . . . . . . . . . . . . 376
Folder . . . . . . . . . . . . . . . . . . . . . . . . 359
Flashkit . . . . . . . . . . . . . . . . . . . . . . . 376
Creating a New main.fla . . . . . 359
xii Macromedia Flash 8 @work: Projects You Can Use on the Job
We’re Here . . . . . . . . . . . . . . . . . . . . 376
Ultrashock . . . . . . . . . . . . . . . . . . . . 376
Third-Party Products . . . . . . . . . . . . . . . . 377
ActionScript Viewer . . . . . . . . . . . 377
Swift 3D . . . . . . . . . . . . . . . . . . . . . . . 377
Toon Boom Studio . . . . . . . . . . . . 377
Flix . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
Sorenson Media . . . . . . . . . . . . . . . 377
Techsmith’s Camtasia. . . . . . . . . 377
Zoomify . . . . . . . . . . . . . . . . . . . . . . . 377
SWF Studio . . . . . . . . . . . . . . . . . . . . 378
M Projector . . . . . . . . . . . . . . . . . . . 378
Zinc V2 . . . . . . . . . . . . . . . . . . . . . . . 378
Screenweaver . . . . . . . . . . . . . . . . . 378
Content Site . . . . . . . . . . . . . . . . . . . . . . . . . 378
Moving Image Internet
Archive . . . . . . . . . . . . . . . . . . . . . . 378
B Components 379
Using V2 Components . . . . . . . . . . . . . . 379
Simple Listener . . . . . . . . . . . . . . . 379
Using a Custom Object As a
Listener . . . . . . . . . . . . . . . . . . . . . . 382
Using mx.utils.Delegate . . . . . . 383
Instantiating Components
Dynamically . . . . . . . . . . . . . . . . . . . . . . 384
Dispatching Events . . . . . . . . . . . . . . . . . 384
Where to Go from Here . . . . . . . . . . . . . 386
Glossary 387
Index 397
Contents xiii
About the Author
Phillip Kerman has been teaching Flash since version 3 and writing books since version 5.
He also does contract development. His early experiences in photography have a direct
correlation to his job today. The feeling he gets when seeing a project he assembles come to
life is the same as watching a photograph develop in the darkroom.
Although he understands that great projects involve the work of many dedicated people,
he’s not shy to point out that he was the primary programmer for such familiar projects as
the original Millennium Three site (archived at deepplay.com/sites/
m399/), a real-time Flash auction that consistently sells over $5 million in cattle during a
typical 90-minute sale (stampedecattle.com), the site for the “other” cool office chair
(www.allsteeloffice.com/number19/movie.asp), and the Witness to History kiosk featured in
the Communication Arts 11th Annual Interactive Exhibition (commarts.com/ca/interac-
tive/cai05/36_ia05.html).
The short story of Phillip’s rise from mere mortal to being in charge of everything at
phillipkerman.com LLC goes like this:
. Student photographer for Sunset High School’s newspaper and yearbook
. Rode his bicycle from Portland, Oregon, to go to college in Rochester, New York (and
got all 2 years’ worth of physical education credits waived in the process)
. Graduated from the Rochester Institute of Technology with a bachelor of science in
imaging and photographic technology
. Worked for Sinar Bron, Inc., selling premier professional photographic
equipment
. Worked for The Human Element, Inc., doing Authorware (version 1)
development
. Drove back to Portland, Oregon, where he has been doing contract work for more
than 10 years
Dedication
This book is dedicated to my good friend of 25 years, Graham Stewart Clark (1964–2005).
Graham was a brilliant, inspiring, and strong human being who fought and lost a silent
battle against overwhelming unhappiness. May his suicide persuade us of the importance
of seeking help for ourselves and those we love.
For my friend, a city planner who dreamed of creating a more livable city, will you the
reader consider giving your car a rest once in a while and instead walk, ride a bike, or take
public transportation?
Acknowledgments
It’s fair to say this book would be much different if no one helped me write it. In fact, I
suspect it would be bad.
General acknowledgements, like those that follow, help reduce the chances of leaving
anyone out. The people at Macromedia are always accessible and responsive. In the case of
the Flash 8 team, though, they outdid themselves with a great product and a super-effective
beta process. I’ve tried listing specific Macromedians in my other books’ acknowledgements
and, even when the list contains more than 100 people, I inevitably forget someone (so I’m
not going to risk that here).
The folks at Sams Publishing are also super-dedicated and professional. For better or worse,
they’re unlike any of my other clients. They really approach a book as a partnership in
which everyone can help make it better. Not once have I felt that a negotiation (big or
small) was resolved unfairly.
If you’ve ever tried teaching, you won’t be surprised to hear me acknowledge all the
students who have taught me something. You tend to find out what you don’t know very
quickly when you teach. And, as is true with many other challenges, there is always room
to improve your teaching ability. In recent years, I’ve learned from students and other
teachers at Cleveland High School, Northwest Academy, Pacific Northwest College of Art,
Portland Community College, and West Linn High School.
There are also people who provided specific help with certain portions of the book. Burak
Kalayci (www.buraks.com)—whose ActionScript Viewer (ASV) and Captionate products are
enough to deserve special recognition—provided valuable insights into how to design the
projects for Chapter 3, “Creating a Video with Synchronized Captions.” He also graciously
reviewed some other portions of the book. A former student, Jhon Adams (www.evilpump-
kin.com), created the PHP components for Chapter 6, “Saving and Evaluating Quiz
Results,” and Chapter 10, “Building a Photo Share Application.” My sister, Deborah
Kerman, provided expert advice on the
question-writing tips in Chapter 5, “Creating an Assessment Quiz.” Jesse Warden
(www.jessewarden.com) also graciously reviewed a chapter early on, which helped me to
map out other projects. Larry Drolet, Scott Huber, Doug Scamahorn, and David Vogeleer all
tested several chapters’ functionality. The prolific Flash author Robert Reinhardt
(www.themakers.com) gave me lots of general feedback over the weeks (well, months) it
took me to write this book.
Finally, I’ve seen some authors acknowledge musical artists (presumably those who influ-
enced the author while writing). Instead, let me mention the killer stereo accessory called
squeezebox (from www.slimdevices.com) that gave me an easy way to listen to music while
writing.
We Want to Hear from You!
As the reader of this book, you are our most important critic and commentator. We
value your opinion and want to know what we’re doing right, what we could do better,
what areas you’d like to see us publish in, and any other words of wisdom you’re
willing to pass our way.
You can email or write me directly to let me know what you did or didn’t like about
this book—as well as what we can do to make our books stronger.
Please note that I cannot help you with technical problems related to the topic of this book,
and that due to the high volume of mail I receive, I might not be able to reply to every
message.
When you write, please be sure to include this book’s title and author as well as your
name and phone or email address. I will carefully review your comments and share
them with the author and editors who worked on the book.
Email:
[email protected]
Mail: Mark Taber
Associate Publisher
Sams Publishing
800 East 96th Street
Indianapolis, IN 46240 USA
Reader Services
For more information about this book or another Sams Publishing title, visit our
website at www.samspublishing.com. Type the ISBN (excluding hyphens) or the title of
a book in the Search field to find the page you’re looking for.
Introduction
A lot of books claim that they’re unique, but
this one really is. The @ work series leads you
directly into building the kinds of practical
projects you’re likely to encounter in a profes-
sional environment. That promise has
appeal because readers have a very clear
idea of what they want to build. The projects
in this book are definitely in demand. (I
know because all these projects have come
up more than once in my job.) However, the
idea that you can bypass details and learn
just the facts is a potential fallacy that
threatens the premise of this book series. In
fact, I’d argue that there are only a few ways
to learn difficult subjects and, unfortunately,
none are “quick and easy.”
In case you think I’m a walking contradic-
tion, let me explain how this book can be to
the point without being so “lite” that the
projects aren’t useful. It might sound terrible,
but in this book you won’t learn the Flash
skills needed to build complex projects. But
the projects you’ll build aren’t lightweight
either. Rather, for each chapter, I’ve built
adaptable support files that serve as engines
that display your content. What you’ll learn
here is how to adapt and extend these
engines for your projects. (Of course, you’ll
be able to investigate the files to see how I
built them, but the focus is on using these
files.)
These engines are not merely templates that
you fill with your own content, switch a few
colors, and then put your logo on. In fact,
the engines are invisible. For example, when
you add captions to a video (in Chapter 3,
“Creating a Video with Synchronized explain every step in detail, but I also know
Captions”), you create the text display and that it’s easy to get lost if you’ve never
supply the actual captions. The engine touched Flash. The target audience for this
handles the bulk of the timing and program- book is an accomplished novice or intermedi-
ming tasks and then simply sends a message ate Flash user. A lot of people learn how to
to your display when a new caption should create animations and projects with simple
appear. Here’s a wild analogy to illustrate interactivity but then hit a wall that blocks
how it works: Think of how you’re insulated them from tackling advanced projects. I’m
from the details involving exactly how your writing for the reader who’s at that wall but
car works. You only have to interface with who wants to learn only how to get over the
the steering wheel, gas pedal, and brakes. wall at hand—the projects at hand in your
Now imagine if your car had modular work today.
components enabling you to change and
This book is not a guide to Object Oriented
modify everything in the interior. As long as
Programming (OOP). Although all the code
you always included some sort of steering
in my engines uses OOP as well as
wheel, gas pedal, and brakes, the whole
ActionScript 2 (AS2), you can build the proj-
system would work.
ects using any style you want: You can do
I know the engines in this book work because everything in the Flash timeline or make
I’ve already seen them customized and your own class files (that is, use AS2). You
extended by several book reviewers. don’t need any AS2 experience. The only
Furthermore, after writing the chapters, I AS2-specific task you must complete is to
began creating more and more templates copy .as files into the folders in which you’re
that work within the engines (and you building the projects. All my source files are
can download these from www. open for your perusal (which, for me, is a lot
samspublishing.com). I also expect readers like appearing in public in my underwear—
will develop even more templates and email not that I’ve done that). I’m not a hack
them to me to share. (Making templates for programmer by any means, but don’t expect
the engines is easy; that’s one of the main the source files to be the most elegant exam-
things you’ll be doing in this book.) ples of OOP you’ve ever seen. They will, of
course, work for the task at hand and won’t
Let me conclude with a few contrasting notes
have a negative impact on performance.
about what this book is and isn’t, and who
it’s written for. This book is appropriate for a Every project in this book assumes you’re
wide range of readers; some of you will delivering content to Flash Player 8. I
simply replace a few colors and add your suppose that’s not totally practical because
logo to the finished files I supply, while many clients don’t want to require their users
others will create very advanced templates to have the latest version of the Flash plug-in
that adapt and extend my engines. You’ll until after it has been out a while. (However,
definitely get a lot more out of the book if in Chapter 1, “Exploring Flash 8,” I give you
you’re familiar enough with Flash that evidence for why the adoption rate is likely
you’re not fighting with its interface. I to occur quickly with Flash Player 8.) The
reason the projects use features that require
2 Macromedia Flash 8 @work: Projects You Can Use on the Job
Flash Player 8 is not arbitrary. In every case, wanted to insert an additional feature I
I’m embracing new features that either didn’t think of. In such cases, feel free to
provide results previously unavailable or email me at
[email protected], and I
because they make the development of the might be motivated to actually build it—at
project much easier. worst, I can point you in the right direction
to help you build it yourself.
The engines in this book are not Flash
components. You won’t receive a library of
advanced UI components. Nor are the
engines standalone applications. However, I
Organization of This Book
did build a few helper applications that This book is divided into three parts:
turned out very cool. For example, one tool
lets you add cue points to video and audio in . Part I, “Getting Started,” introduces
a very natural manner during video play- Flash 8 and provides your basic train-
back. I should also add that you won’t find a ing for building projects in Flash. The
bunch of clipart in the files I’ve made avail- two chapters in this part are really the
able for you to download from the accompa- prerequisites for the rest of the book;
nying CD-ROM. I hope I don’t see a real don’t skip them.
project in which a reader uses my prototype . Part II, “Projects,” contains a variety of
graphics. Not that I mind, but they’re pretty practical projects that are sure to come
rough. up in some form during your Flash
You are welcome to use any of the code from career. They’re not in any particular
this book in your real projects. You have no order and have little overlap or cross
further obligation to me and, similarly, referencing. Therefore, you can read
there’s no stated or implied guarantee that I them in any order. For example, if you
will support the files (beyond maintaining need to add captions to a video, start
the book errata). My point is simply that the with Chapter 3, “Creating a Video with
projects really are ready for primetime and I Synchronized Captions.” If you need to
expect you to use them. make a PowerPoint-like presentation,
jump directly to Chapter 7, “Creating a
Finally, for the third time, I’ll reiterate that PowerPoint-style Slide Presentation.” In
the projects are not lightweight. While I was each chapter you’ll start by building a
writing them, I refused to build something basic working version of the project and
that wasn’t representative of a real project then go on to add enhancements and
(and therefore was impractical). I’ve yet to variations as you wish. For example,
persuade a client that we should remove a you’ll create a quiz in Chapter 5,
useful feature just because I found it hard to “Creating an Assessment Quiz,” and
build, so I didn’t use excuses here either. have the opportunity to add all kinds
Having said that, it’s possible you will want a of question types (such as multiple-
specialty feature added to one of the engines. choice and drag-and-drop). The chap-
Realize that you’ll learn how to make pretty ters in this portion of the book contain
significant changes to the projects through- the projects you can use on the job.
out this book. I wouldn’t be surprised if you
Introduction 3