Webster Yard McSharry Foundation FOUNDatiON FL A Actionscript 3.0 CTI with Flash CS3 and Flex AS In this book, you’ll learn how to: Also Available Use the fundamentals of ActionScript 3.0 with both the Flash IDE and Flex Take advantage of ActionScript 3.0’s object-oriented features Steve Webster H CS3 ONS Manipulate sound and video to produce exciting modern web applications Work with XML as your data source Todd Yard Witness the power of ActionScript 3.0 in two complete case studies Sean McSharry Foundation ActionScript 3.0 with Flash CS3 and Flex C ctionScript 3.0, the latest version of the Flash Platform’s scripting language, Aoffers a lot of new and powerful features. ActionScript is now a full-fledged R programming language, with complete object-oriented capabilities, improved event handling, sound and video support, drawing capabilities, support for regular A IPT expressions, and much more. ND Whether you are a Flash designer wishing to add to your skill set or an experienced ActionScript developer who wants to get up to speed with the latest version, you’ll FLEX find all you need to know in Foundation ActionScript 3.0 with Flash CS3 and Flex. This book covers all the essential techniques from the ground up, allowing you to get 3.0 up and running quickly and easily. Starting with the fundamentals, you’ll learn about using ActionScript objects, manipulating sound and video, and harnessing the power of regular expressions and XML. The book concludes with two case studies to consolidate what you’ve learned and to introduce some more advanced techniques. This will give you a good grounding in the new and exciting world of ActionScript 3.0 and show you how it all fits together WIT in larger applications, allowing you to go on and build your own professional sites. The sensible layout of the book makes it easy to find information about specific techniques. It doesn’t aim to be an exhaustive reference, but rather focuses on the H essential skills that will enable you to get up and running quicker. With this book as your guide, you’ll be creating killer Flash applications before you know it. ISBN-13: 978-1-59059-815-3 SHELVING CATEGORY ISBN-10: 1-59059-815-6 1. FLASH 5 3 9 9 9 2. WEB DEVELOPMENT Add ActionScript 3.0 functionality to your Flash movies and applications US $39.99 Mac/PC compatible Learn essential real-world techniques to get up and running quickly 9 781590 598153 www.friendsofed.com See how you can use ActionScript 3.0 in both Flash CS3 and Flex this print for reference only—size & color not accurate spine = 1.1015" 584 page count 8156fm.qxd 11/12/07 11:29 AM Page i Foundation ActionScript 3.0 with Flash CS3 and Flex Steve Webster, Todd Yard, and Sean McSharry 8156fm.qxd 11/12/07 11:29 AM Page ii Foundation ActionScript 3.0 with Flash CS3 and Flex Copyright © 2008 by Steve Webster, Todd Yard, and Sean McSharry 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-815-3 ISBN-10 (pbk): 1-59059-815-6 ISBN-13 (electronic): 978-1-4302-0196-0 ISBN-10 (electronic): 1-4302-0196-7 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 [email protected], or visit www.springeronline.com. For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], 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 Lead Editors Senior Production Editor Ben Renow-Clarke, Chris Mills, and Matthew Moodie Laura Cheu Technical Reviewer Compositor Mike Jones Molly Sharp, ContentWorks Artist Editorial Board Kinetic Publishing Services, LLC Steve Anglin, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Jason Gilmore, Kevin Goff, Proofreader Jonathan Hassell, Matthew Moodie, Joseph Ottinger, Nancy Riddiough Jeffrey Pepper, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Indexer Carol Burbo Senior Project Manager Tracy Brown Collins Cover Image Designer Corné van Dooren Senior Copy Editor Interior and Cover Designer Marilyn Smith Kurt Krames Associate Production Director Manufacturing Director Kari Brooks-Copony Tom Debolski 8156fm.qxd 11/12/07 11:29 AM Page iii To Audrey, who has unwittingly served as a model for nearly every photo I’ve put into a book for the past three years. Thanks for taking a great picture and understanding why Daddy needs to work sometimes instead of jumping around like a bunny. —Todd Yard To Mary: Thank you for being so patient with me and bringing up our kids while I work 24 hours a day. I’m not going to do this again . for a while. To my boys Aston and Jack: I promise you will finally get to see Daddy’s face again, and yes, we can go to the beach and play golf again. To Isabelle, my new baby daughter: Welcome to the world. It’s an amazing, bright, boundless place, and you have made it more so. You have all given me the strength to do so much over the last year. I love you all very much and promise I will go to bed every night from now on. And finally . Mary, will you marry me? . and finally make our children respectable? —Sean McSharry 8156fm.qxd 11/12/07 11:29 AM Page iv 8156fm.qxd 11/12/07 11:29 AM Page v CONTENTS AT A GLANCE About the Authors . xvii About the Technical Reviewer . xviii About the Cover Image Designer . xix Chapter 1 Getting Started with ActionScript 3.0 . 3 Chapter 2 ActionScript 3.0 Fundamentals . 25 Chapter 3 Objects and classes . 71 Chapter 4 Working with the Display. 109 Chapter 5 Creating Vector Graphics with the Drawing API. 163 Chapter 6 User Interaction and More with Events . 193 Chapter 7 Working with Video . 233 Chapter 8 Using Audio. 293 Chapter 9 Working with Components . 345 Chapter 10 Regular Expressions . 393 Chapter 11 Using XML . 419 Chapter 12 Case Study: Creating a Dynamic Image Viewer . 435 Chapter 13 Getting Started with Flex 2 . 469 Chapter 14 Flex by Example . 491 Index . 550 v 8156fm.qxd 11/12/07 11:29 AM Page vi 8156fm.qxd 11/12/07 11:29 AM Page vii CONTENTS About the Authors . xvii About the Technical Reviewer . xviii About the Cover Image Designer . xix Chapter 1 Getting Started with ActionScript 3.0 . 3 A brief history of ActionScript. 4 Flash CS3 and Flex 2 . 4 ActionScript and object-oriented programming. 6 The development process . 6 Organizing your files . 9 Adding ActionScript to your projects . 10 Placing code on the timeline . 10 Importing code from an external file. 12 Specifying a document class. 13 Linking library assets to external classes . 14 Bouncing balls. 17 Creating the Flash file . 17 Creating the Ball class . 19 Adding more balls . 21 ActionScript in action. 22 Summary . 23 Chapter 2 ActionScript 3.0 Fundamentals . 25 Statements and expressions . 26 Introducing variables . 27 Assigning a value to a variable. 28 Retrieving the value of a variable . 29 Naming your variables . 31 Understanding data types . 32 Boolean data type . 33 Numeric data types . 33 vii 8156fm.qxd 11/12/07 11:29 AM Page viii CONTENTS Constants . 35 Performing operations . 36 Arithmetic operators. 36 Specifying precedence . 37 String operations . 38 Unary operations . 38 Introducing arrays. 39 Manipulating arrays. 41 Making decisions . 43 Introducing the if statement. 43 Forming Boolean expressions . 44 Booleans in conditionals. 46 Using Boolean operators . 47 Looping the loop . 48 The while loop . 49 The do . while loop . 52 The for loop. 53 Looping through an array . 53 More for loops . ..
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages587 Page
-
File Size-