ActionScripting in Macromedia Flash MX

  
   
  Table of Contents
  NOTE
ActionScripting in Macromedia Flash MX
By Phillip Kerman
   
Publisher : New Riders Publishing
Pub Date : July 18, 2002
ISBN : 0-7357-1295-6
Pages : 700

Tap into the full power of Flash MX by learning how and when to employ ActionScripting. ActionScripting in Flash MX is structured into 2 parts. In the Foundation section readers learn general programming theory and how it applies to Flash. Then the book progresses through more complex Flash ActionScripting applications, including functions, arrays, objects, components, and interfacing with external data. Short tasks and real-world analogies demonstrate specific concepts. In the Workshop section, the reader actually builds practical applications that range in complexity from beginner to advanced. At the end of the Workshop section, the reader will actually debug broken scripts.

777

Copyright
    Acknowledgments
    About the Author
    Tell Us What You Think
    Foreword
    Part I:  Foundation
      Chapter 1.  Flash Basics
      Timeline Hierarchy
      Script Locations
      Always Movie Clips
      Coordinate System
      Tricks of the Trade
      Summary
   
      Chapter 2.  What's New in Flash MX
      General Enhancements
      Features for Programmers
      Book Conventions and Expectations
      Summary
   
      Chapter 3.  The Programmer's Approach
      Specification
      Prototyping
      Good Style
      Code Data Separation
      Summary
   
      Chapter 4.  Basic Programming in Flash
      Terminology, Special Characters, and Formatting
      Data Types and Variables
      Using Variables
      Dot Syntax
      Summary
   
      Chapter 5.  Programming Structures
      Statements, Expressions, and Operators
      Simple Objects in Statements
      Conditional and Loop Statements
      Applied Expression Writing
      Summary
   
      Chapter 6.  Debugging
      General Approaches to a Bug-Free Life
      Using the Debugger
      Summary
   
      Chapter 7.  The Movie Clip Object
      Properties of Clips
      Variables in Clips (or "Homemade Properties")
      Methods of Clips
      Referencing Clips and Addressing
      Summary
   
      Chapter 8.  Functions
      How to Use Functions
      Creating Homemade Functions
      Applying Functions to Previous Knowledge
      Summary
   
      Chapter 9.  Manipulating Strings
      String Object Form
      Methods of the String Object Explored
      Summary
   
      Chapter 10.  Keyboard Access and Modifying Onscreen Text
      The Two "Text" Objects: TextField and TextFormat
      Selection Object
      Key Object
      Summary
   
      Chapter 11.  Arrays
      Array Overview
      Array Creation and Manipulation
      Loops
      Associative Arrays
      Summary
   
      Chapter 12.  Objects
      Formal Rules of Objects
      Attaching Sounds
      Attaching Colors to Clips
      The Date Object
      Implications for Movie Clips
      Summary
   
      Chapter 13.  Homemade Objects
      Basic Objects
      A Practical Example of Homemade Objects
      Summary
   
      Chapter 14.  Extending ActionScript
      Callback Functions
      Registering Custom Classes
      Listeners and Watchers
      Overriding Built-In Methods
      Setting Scripts to Trigger on Schedule
      Summary
   
      Chapter 15.  Components
      Components Overview
      Replacing the Component Parameters Panel (or the Properties Panel's Parameter Tab) with a Custom UI
      Summary
   
      Chapter 16.  Interfacing with External Data
      External Scripts
      Setting Flash Variables from Within HTML
      External Data Files
      Server Scripts
      XML
      Local SharedObjects
      The LocalConnection Object
      Summary
   
   
    Part II:  Workshops
      {Workshop} Introduction
   
    Part IIA:  Basic Workshops
      Workshop Chapter 1.  Ensuring That Users Have the Flash Player 6
      Workshop Chapter 2.  Creating Custom Cursors
      Workshop Chapter 3.  Creating a Horizontal Slider
      Creating a Quick-and-Dirty Slider
      Converting the Slider into a Component
      Summary
   
      Workshop Chapter 4.  Building a Slide Show
      Workshop Chapter 5.  Mapping and Scripted Masks
      Workshop Chapter 6.  Working with Odd-Shaped Clickable Areas
      Workshop Chapter 7.  Adapting Built-In Components
      Populating Components
      Editing Scripts in Components
      Skinning a Component
   
   
    Part IIB:  Intermediate Workshops
      Workshop Chapter 8.  Creating a Currency-Exchange Calculator
      Workshop Chapter 9.  Creating a ToolTip Component
      Workshop Chapter 10.  Creating Timers
      Creating a Digital Timer
      Creating an Analog Timer
      Creating a Countdown Timer
      Summary
   
      Workshop Chapter 11.  Using Math to Create a Circular Slider
      Workshop Chapter 12.  Developing Time-Based Animations
   
    Part IIC:  Advanced Workshops
      Workshop Chapter 13.  Drawing Graphs
      Using the Drawing Methods
      Dynamic Text Labeling
   
      Workshop Chapter 14.  Offline Production
      Workshop Chapter 15.  Creating a Dynamic Slide Presentation
      Workshop Chapter 16.  Using the Local SharedObject to Remember User Settings
      Workshop Chapter 17.  Using the LocalConnection Object for Inter-Movie Communication
      Workshop Chapter 18.  Fixing Broken Scripts
      Card Flip
      Card Snap
      Circle Move
      Multiple Choice
      Rotating Box
      Word Float
      Yellow Box
      Click and Hold
      Objects
      Move Multiple
      Summary

Copyright

Copyright 2003 by Phillip Kerman

FIRST EDITION: July, 2002

All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage and retrieval system, without written permission from the publisher, except for the inclusion of brief quotations in a review.

Library of Congress Catalog Card Number: 2002101433

06 05 04 03 02 7 6 5 4 3 2 1

Interpretation of the printing code: The rightmost double-digit number is the year of the book's printing; the rightmost single-digit number is the number of the book's printing. For example, the printing code 02-1 shows that the first printing of the book occurred in 2002.

Printed in the United States of America

Trademarks

All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. New Riders Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Macromedia Flash MX is a registered trademark of Macromedia.

Warning and Disclaimer

This book is designed to provide information about Macromedia Flash MX. Every effort has been made to make this book as complete and as accurate as possible, but no warranty of fitness is implied.

The information is provided on an as-is basis. The authors and New Riders Publishing shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book or from the use of the discs or programs that may accompany it.

Credits

Publisher

David Dwyer

Associate Publisher

Stephanie Wall

Production Manager

Gina Kanouse

Executive Editor

Jeff Schultz

Acquisitions Editor

Kate Small

Development Editor

Damon Jordan

Product Marketing Manager

Kathy Malmloff

Publicity Manager

Susan Nixon

Project Editors

Stacia Mellinger

Beth Trudell

Copy Editor

John Sleeva

Technical Editor

Matthew Manuel

Indexer

Chris Morris

Manufacturing Coordinator

Jim Conway

Book Designer

Alan Clements

Cover Designer

Aren Howell

Proofreader

Linda Seifert

Composition

Amy Parker

Dedication

Dedicated to my entire family, including our newest member, Savannah and to the canine Kerman, Max, who deserved more walks than he got during the writing of this book.

Acknowledgments

The hardest part of writing a book is attempting to acknowledge all those who helped, but knowing that you'll fail to mention everyone. Here is my attempt to acknowledge everyone.

First, the people at New Riders. You'll find a list of the key players in the credits column on the copyright page, but even they would acknowledge that others helped them. After seeing my first book become a reality, I realized that even if I could write a perfect book on my own (which, of course I can't), it would never get printed because so much work is involved in preparing the files for the printer. Although I can't say I know how every publisher works, I can say that New Riders is professional, responsive, and fun. Of particular note, Kate Small and Damon Jordan made the book flow. Everything seemed to make sense when I wrote it, but after Kate and Damon reorganized parts, it made much more sense. Matthew Manuel used his Flash experience both to ensure that technical details were correct and exercises could be performed, as well as to suggest countless additional facts that were included in the text. A copy editor like John Sleeva is doubly valuable because he eliminates errors that would otherwise make the book difficult to read, and he makes me a better writer! Reviewing his edits is like a free English class. Obviously, there are many others who work behind the scenes for whom I am grateful.

Macromedia continues to amaze me with its forthcoming and approachable style. The company is totally involved in email lists and Flash community sites. The folks who seem to go way beyond the call of duty by providing help to all include Jeremy Allaire, Brad Bechtel, Damian Burns, Mike Chambers, Jeremy Clark, Henriette Cohn, John Dowdell, Ken Eckey, Allen Ellison, Gary Grossman, Erica Norton, Nigel Pegg, Peter Santangeli, Sharon Selden, Christopher Thilgen, Michael Williams, Eric J. Wittman, and Matt Wobensmith.

I subscribe to many email lists, but three in particular have been most helpful: those run by Branden Hall, Jon Warren Lentz, and Darrel Plant. There are countless instances when a thread on one of these lists has helped me.

One last acknowledgment for some authors of other Flash books. I'm proud of this book, but it contains only my style of communication. For some different perspectives on Flash, check out books containing contributions by the following authors:

Joshua Davis, Brendan Dawes, David J. Emberton, Bruce Epstein, Derek Franklin, Garo Green, Branden Hall, Andreas Heim, Jon Warren Lentz, Kim Markegard, Colin Moock, Robert Penner, Darrel Plant, Robert Reinhardt, Crissy Rey, Gary Rosenzweig, Nik Schramm, Glenn Thomas, Phillip Torrone, Bill Turner, and Samuel Wan.

I can't vouch for books I haven't reviewed, but I can say these folks know their stuff. They've also provided direct help on various Flash-related matters to myself and others for years.

Phillip Kerman

About the Author

Phillip Kerman is an independent programmer, teacher, and writer specializing in Macromedia products. His degree in Imaging and Photographic Technology from the Rochester Institute of Technology was earned back when "multimedia" had a different meaning than today. One of Phillip's internships, for example, involved programming multiple slide projector presentations with dissolves synchronized to a sound track the multimedia of the 1980s. In 1993, he found Macromedia Authorware a natural fit for his interest and skills. After getting his start at The Human Element, Inc., he moved back to Portland, Oregon to work on his own.

Phillip has transitioned his expertise from Authorware to Director, and now, to Flash. Over seven years, he has had to adapt to a total of 16 version upgrades Flash MX being the most significant of them all! In addition to retooling and building his own skills, Phillip finds teaching the biggest challenge. He has trained and made presentations around the world, in such exotic locations as Reykjavik, Iceland; Melbourne, Australia; Amsterdam, Holland; and McAlester, Oklahoma. He is also the best-selling author of Sams Teach Yourself Macromedia Flash MX in 24 Hours (that is the title, not how long it took to write). His writing has also appeared in publications such as Macworld, Macromedia User Journal, and his self-published The Phillip Newsletter (www.phillipkerman.com/newsletter).

In addition to showing others how to create multimedia, Phillip has had plenty of opportunities to get his hands dirty in programming. You can see a recent Flash site he programmed at www.allsteeloffice.com/number19.

Feel free to email Phillip at flash6@phillipkerman.com.

Tell Us What You Think

As the reader of this book, you are the 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.

As the Associate Publisher for New Riders Publishing, I welcome your comments. You can fax, 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 fax number. I will carefully review your comments and share them with the author and editors who worked on the book.

Fax:

317-581-4663

Email:

stephanie.wall@newriders.com

Mail:

 

Stephanie Wall 
Associate Publisher 
New Riders Publishing 
201 West 103rd Street 
Indianapolis, IN 46290 USA

 

Foreword

You might not think that the upgrade to Macromedia Flash MX is quite as significant as the upgrade to Flash 5. For a programmer, however, it's certainly the biggest upgrade ever. Whereas anything was possible before, now it's also elegant, efficient, and easy. Of course, you have to become a programmer first. If you just organize your goals and translate them into the language of a programmer, you can make Flash do precisely what you imagined. But therein lies the problem: Not everyone can translate goals into a programming language.

This book targets the reader who can assemble a basic Flash movie and who knows what he or she wants to achieve. I'll help you divide your goal into individual tasks that can then be translated into ActionScript. Naturally, this will involve teaching you how to "program" (and even how to think like a programmer). This book, however, is not a general programming book; every topic is related to and applied to Flash. Naturally, if you are already an experienced programmer, you might find parts of this book to be a review. But for you programmers, I'll show you how to apply your programming knowledge to make Flash perform. All the programming skill in the world (whether I teach it to you or you bring it with you) won't help you if you can't apply it to Flash.

Although this book definitely does not shy away from advanced topics, it isn't an exhaustive reference to every detail in the ActionScript language. The truth is that there are countless other resources for advanced programming topics. That's not what this book is about. It's about giving you the skills so that you can apply any idea you have to Flash. When you're equipped with the knowledge I cover, you'll be able to meet any challenge. It might involve researching an esoteric formula for physics or applying a unique math calculation. If that means you have to research a specific topic, this book will give you the skills to figure out how to apply it to Flash.

This book is an overhaul of ActionScripting in Flash (covering Flash 5). Believe me, I didn't just do a "find-and-replace" to change all the 5s to MXs! (I wish it were that easy.) For the most part, this book is just more. I cut out plenty, but added much more. The general programming topics didn't change much, but anything specific to Flash (most of the book) went through significant changes. I think readers can learn two things from this book: how to be a programmer and how to harness Flash's ActionScript language. The major difference between this book and the previous one on Flash 5 is that harnessing ActionScript is much different now.

The book is organized in two parts. The chapters in Part I, "Foundation," are like chapters in a textbook. Plenty of examples are interspersed, but you don't need to follow along with Flash running. (I suspect that you'll be inspired to try things out often, however.) Part II, "Workshops," features hands-on tutorials. They offer you a chance to apply what you've learned in Part I. If you prefer, you can jump right into the workshop chapters. (References are made to the chapters in Part I when further explanation might be helpful.) You'll find the workshop chapters to be quite useful. In many of them, I even guide you down the wrong path so that we can discuss the solution that follows. I find that this is more true-to-life than some tutorials that seem to prove only that it's possible to achieve a particular result with very few steps. Real life is often frustrating, and perhaps the simulated reality of these workshop chapters will help you avoid frustration when you go on your own.

One last note before we get rolling: Flash MX was such a change from Flash 5 that I chose to cover only Flash MX. It turns out that there are a few ancillary mentions of older versions of Flash in this book. By and large, however, this book is for Flash MX only. Workshop Chapter 1 provides information about ensuring that your users have the correct Flash Player. Naturally, I'll show you how to upgrade those users so that they can see your Flash MX creations.

Now get ready to transform yourself from a Flash user to an ActionScripter!



ActionScripting in MacromediaR FlashT MX
ActionScripting in MacromediaR FlashT MX
ISBN: N/A
EAN: N/A
Year: 2001
Pages: 41

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net