Tài liệu FriendsofED Object Oriented ActionScript 3.0 Jul 2007 doc

640 1.5K 1
Tài liệu FriendsofED Object Oriented ActionScript 3.0 Jul 2007 doc

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

this print for reference only—size & color not accurate spine = 1.206" 640 page count PETER ELST SAS JACOBS TODD YARD CYAN YELLOW MAGENTA BLACK US $49.99 Mac/PC compatible www.friendsofed.com ISBN-13: 978-1-59059-845-0 ISBN-10: 1-59059-845-8 9 781590 598450 5 4 9 9 9 SHELV IN G CAT EG OR Y 1. FLASH Inside you’ll learn » The essential principles of object-oriented programming, including inheritance, encapsulation, polymorphism, and more » Valuable lessons on ActionScript 3.0 project planning and programming, including design patterns and source control » How to create your own extensible, reusable application framework using OOP best practices » Advanced data integration techniques such as Web Services and communication between Flash and the browser Object-Oriented ActionScript 3.0 O bject-oriented programming (OOP) is something that is usually considered a black art for hardcore programmers, not a topic of conversation for Flash developers. However, when Adobe introduced ActionScript 3.0 to the mix, it changed everything. ActionScript 3.0 is much more powerful than previous versions, allowing Flash developers to produce robust object-oriented applications. But with that power comes great responsibility—OOP is now a requirement, rather than optional, and there are new things to learn. But never fear—this book, based on the ever-popular Object-Oriented ActionScript for Flash 8, provides you all you need to delve into the world of OOP with confidence, whether you are using the Flash IDE, Flex Builder, or even command-line tools for your development work. First, you are taken gently through all the principles of OOP that you need to know, and then given a guide to designing and implementing applications in ActionScript 3.0. Next, we step up a gear, showing you the Flex Builder development environment and teaching about creating reusable, extensible component frameworks—manager classes, animation and effects classes, UI widgets, and more. Lastly, we look at some more advanced topics such as communication between Flash and the browser and Web Services. Case studies are included that apply the knowledge presented, giving you real-world projects to learn from and adapt for use in your own work. Mastering object-oriented programming is essential for modern Flash development, and Object-Oriented ActionScript 3.0 is the only guide you’ll need. » Learn object-oriented programming in ActionScript 3.0 » Covers both the Flash and Flex environments » Includes design patterns, custom frameworks, data binding, and other crucial techniques Elst Jacobs Yard ALSO AVAILABLE friends of ED ADOBE ® LEARNING LIBRARY OBJECT-ORIENTED ACTIONSCRIPT 3.0 Object-Oriented ActionScript 3.0 Peter Elst Sas Jacobs Todd Yard 8458FM.qxd 6/15/07 11:41 AM Page i Object-Oriented ActionScript 3.0 C opyright © 2007 by Peter Elst, Sas Jacobs, and Todd Yard A ll rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, e lectronic or mechanical, including photocopying, recording, or by any information storage or retrieval s ystem, without the prior written permission of the copyright owner and the publisher. I SBN-13 (pbk): 978-1-59059-845-0 ISBN-10 (pbk): 1-59059-845-8 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 T rademarked 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 orders-ny@springer-sbm.com, or v isit 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 info@apress.com, 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. Cover images courtesy of NASA. Credits Lead Editor Chris Mills Technical Reviewer Crystal West Editorial Board Steve Anglin, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jason Gilmore, Jonathan Hassell, Chris Mills, Matthew Moodie, Jeffrey P epper, Ben Renow-Clarke, Dominic Shakeshaft, Matt W ade, Tom Welsh Project Manager Denise Santoro Lincoln Copy Edit Manager Nicole Flores Copy Editor Ami Knox Assistant Production Director Kari Brooks-Copony Production Editor Laura Esterman Compositor Dina Quan Proofreader Linda Seifert Indexer Broccoli Information Management Interior and Cover Designer Kurt Krames Manufacturing Director T om Debolski 8458FM.qxd 6/15/07 11:41 AM Page ii 8458FM.qxd 6/15/07 11:41 AM Page iii CONTENTS AT A GLANCE Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi PART ONE: OOP AND ACTIONSCRIPT Chapter 1: Introduction to OOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Chapter 2: Programming Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Chapter 3: ActionScript 3.0 Programming . . . . . . . . . . . . . . . . . . . . . . 21 PART TWO: FLASH OOP GUIDELINES Chapter 4: Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Chapter 5: Project Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Chapter 6: Best Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Chapter 7: Working with Flex 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 iv 8458FM.qxd 6/15/07 11:41 AM Page iv PART THREE: CORE OOP CONCEPTS Chapter 8: Encapsulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 Chapter 9: Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Chapter 10: Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 Chapter 11: Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 Chapter 12: Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 Chapter 13: Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 Chapter 14: Case Study: An OOP Media Player . . . . . . . . . . . . . . . . . 245 PART FOUR: BUILDING AND EXTENDING DYNAMIC FRAMEWORKS Chapter 15: Manager Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 Chapter 16: UI Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 Chapter 17: OOP Animation and Effects . . . . . . . . . . . . . . . . . . . . . . 381 PART FIVE: DATA INTEGRATION Chapter 18: Exchanging Data Between Components . . . . . . . . . . . . . 437 Chapter 19: Communication Between Flash and the Browser . . . . . . 477 Chapter 20: Server Communication (XML and Web Services) . . . . . . 505 Chapter 21: Case Study: Slideshow Engine . . . . . . . . . . . . . . . . . . . . 549 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599 v 8458FM.qxd 6/15/07 11:41 AM Page v CONTENTS Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi PART ONE: OOP AND ACTIONSCRIPT Chapter 1: Introduction to OOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 The scoop with OOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Understanding the object-oriented approach . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Classes and objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Encapsulation: Hiding the details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Polymorphism: Exhibiting similar features . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Inheritance: Avoid rebuilding the wheel . . . . . . . . . . . . . . . . . . . . . . . . . . 10 What’s next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Chapter 2: Programming Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 About programming slang . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Building blocks of programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 About variable data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 vi 8458FM.qxd 6/15/07 11:41 AM Page vi Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 About calling functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 About function parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Conditionals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 OOP concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 What’s next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Chapter 3: ActionScript 3.0 Programming . . . . . . . . . . . . . . . . . . . . . . 21 ActionScript 2.0 vs. ActionScript 3.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Declaring variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Classes vs. prototypes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Public and private scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Strong typing and code hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 ActionScript gotchas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Case sensitivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Declaring variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Use of the this keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 What’s next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 PART TWO: FLASH OOP GUIDELINES Chapter 4: Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 The importance of planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Initial phase: Planning reusability! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Planning encapsulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Planning inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Analyzing a Flash ActionScript project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Flash files run on the client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Securing data sent to the server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Parsing data in Flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 vii 8458FM.qxd 6/15/07 11:41 AM Page vii Introduction to UML modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 W hy use UML?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 U ML offers standardized notation and has a language-neutral syntax . . . . . . . 46 UML can be used to model anything . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Class diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Association and generalization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Aggregation and composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 What’s next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Chapter 5: Project Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Introducing version control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 About Concurrent Versions System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Using TortoiseCVS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Approaches to programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Rapid Application Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Extreme Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Usability testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 What’s next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Chapter 6: Best Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 External ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 About commenting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Naming conventions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Programming styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Alternative programming styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Coding practices: Peter Elst. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Coding practices: Todd Yard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Coding practices: Sas Jacobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Commenting code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Naming conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 What’s next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Chapter 7: Working with Flex 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 W orking with Flex Builder 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Downloading Flex Builder 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Installing Flex Builder 2 Windows version. . . . . . . . . . . . . . . . . . . . . . . . . . 92 Starting Flex Builder 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Understanding the Flex Builder 2 interface . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 CONTENTS viii 8458FM.qxd 6/15/07 11:41 AM Page viii Getting started with Flex Builder 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 W orking with controls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 B uilding a Flex application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 Creating a Flex project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 Understanding MXML files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 Creating the interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Adding controls to the application . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Adding ID attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 Populating the ComboBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 Creating a new application state. . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 Performing the calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 Running your application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 Debugging applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 Tips for working with Flex Builder 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Creating folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Exporting projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Importing files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Collapsing code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Viewing a quick outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Displaying line numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Adding tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Listing useful shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Compiling SWF files from the command line . . . . . . . . . . . . . . . . . . . . . . . . . 120 What’s next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 PART THREE: CORE OOP CONCEPTS Chapter 8: Encapsulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 Setting up encapsulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Creating new layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 Drawing a background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Aligning and locking the background . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 Drawing a ball . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 Converting the ball into a Library symbol . . . . . . . . . . . . . . . . . . . . . . . . . 132 Content summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Writing the code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Creating an event handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 What about encapsulation? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 T esting the event handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 Updating the ball . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 Improving the code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 Enhancing behavior with properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Narrowing the focus with functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 Encapsulation summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 What’s next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 CONTENTS ix 8458FM.qxd 6/15/07 11:41 AM Page ix [...]... Peter Elst xx 8458FM.qxd 6/15/07 11:41 AM Page xxi INTRODUCTION Hello and welcome to Object- Oriented ActionScript 3.0 We’ve written this book to guide you through the world of object- oriented programming in ActionScript 3.0 As you’ll no doubt know, Adobe revolutionized ActionScript when it introduced ActionScript 3.0 Far from being a minor overhaul, it’s a complete update—we think it’s fair to say... methods of an object (a movie clip, just like everything else in Flash, is an object) However, your applications do not magically become object oriented just because you use xvi 8458FM.qxd 6/15/07 11:41 AM Page xvii objects You can very easily use objects in a procedural manner without practicing objectoriented programming What this book teaches you is to go beyond a mixture of procedural and object- based... Display List API for working with visual objects much more effectively But one of the biggest overriding things to note involves object orientation: whereas with ActionScript 2.0, it was possible, and certainly beneficial, to code your applications the OO way, with ActionScript 3.0 it is completely mandatory But there’s no need to go running for cover object- oriented programming is not something to... do something you need an object If a class is a blueprint, then an object is a house Builders create houses from blueprints; OOP creates objects from classes OOP is efficient You write the class once and create as many objects as needed Because classes can be used to create multiple objects, objects are often referred to as class instances Properties Properties give individual objects unique qualities... tools—see http://osflash.org for more Intended audience This book is aimed at readers who have some previous experience developing in ActionScript and are looking to broaden their knowledge on the latest syntax introduced in ActionScript 3.0 and start writing object- oriented code Some familiarity with the Flash or Flex authoring environments is recommended to be able to easily follow along with the... wouldn’t cut it Object- oriented programming was born as an attempt to solve these very problems Although it certainly isn’t the be-all and end-all of successful programming, OOP does give developers a great tool for handling any kind of application development The wonderful thing about object- oriented thinking is that you can look at practically any item in terms of a collection of objects Let’s look... go beyond a mixture of procedural and object- based programming to understand how to structure your Flash applications in an object- oriented manner It goes beyond the mere use of existing objects to teach you how to model your own objects and structure the communication between objects using good practices OOP is so often presented in such pretentious prose so as to be illegible to all but a handful... Development environment? As alluded to earlier, there are numerous ways to author ActionScript 3.0 content The two most common ways are through Flash CS3 and Flex Builder, but you could also use the free Flex SDK, available at www.adobe.com/products/flex/sdk/, or even open source tools that support development of ActionScript 3.0 One specifically worth mentioning is FlashDevelop (PC only), available at... Using ActionScript expressions Using an E4X expression Binding with an ActionScript function Using the tag Using direct binding Creating multiple bindings with the same controls Using ActionScript expressions Using an E4X expression Binding with an ActionScript function ... (OOP) sounds much scarier than it actually is Essentially OOP is nothing more than a way of looking at a particular problem and breaking it down into smaller pieces called objects These objects form the building blocks of objectoriented applications, and when designed properly they help form a solid framework on which to build your project The scoop with OOP Before OOP became commonplace, we had something . LIBRARY OBJECT- ORIENTED ACTIONSCRIPT 3. 0 Object- Oriented ActionScript 3. 0 Peter Elst Sas Jacobs Todd Yard 8458FM.qxd 6/15 /07 11:41 AM Page i Object- Oriented. Springer- Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 100 13. Phone 1- 800 -SPRINGER, fax 201 -34 8-4 505 , e-mail orders-ny@springer-sbm.com,

Ngày đăng: 10/12/2013, 05:15

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan