1. Trang chủ
  2. » Công Nghệ Thông Tin

OReilly essential actionscript 2 0 jun 2004 ISBN 0596006527

1,1K 50 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 1.141
Dung lượng 3,93 MB

Nội dung

• • • • • • Table of Contents Index Reviews Reader Reviews Errata Academic Essential ActionScript 2.0 By Colin Moock Publisher : O'Reilly Pub Date : June 2004 ISBN : 0-596-00652-7 Pages : 544 In Essential ActionScript 2.0, bestselling author Colin Moock covers everything you'll need to know about the new ActionScript language and its methodologies Experienced Flash developers and programmers coming from other languages will enjoy the sheer depth of Moocks's coverage Novice programmers will appreciate the frequent, low-jargon explanations that are often glossed over by advanced programming books Essential ActionScript 2.0 is the one book every ActionScript coder must own • • • • • • Table of Contents Index Reviews Reader Reviews Errata Academic Essential ActionScript 2.0 By Colin Moock Publisher : O'Reilly Pub Date : June 2004 ISBN : 0-596-00652-7 Pages : 544 Copyright Foreword Preface This Book Wants You What This Book Is Not Who Should (and Shouldn't) Read This Book Deciphering Flash Versions Typographical Conventions We'd Like to Hear from You ActionScript 2.0 Versus ActionScript 1.0 Example Files and Resources Using Code Examples Acknowledgments Part I: The ActionScript 2.0 Language Chapter 1 ActionScript 2.0 Overview Section 1.1 ActionScript 2.0 Features Section 1.3 Flash MX 2004 Version 2 Components Section 1.5 Let's Go OOP Section 1.2 Features Introduced by Flash Player 7 Section 1.4 ActionScript 1.0 and 2.0 in Flash Player 6 and 7 Chapter 2 Object-Oriented ActionScript Section 2.1 Procedural Programming and Object-Oriented Programming Section 2.3 But How Do I Apply OOP? Section 2.2 Key Object-Oriented Programming Concepts Section 2.4 On with the Show! Chapter 3 Datatypes and Type Checking Section 3.1 Why Static Typing? Section 3.2 Type Syntax Section 3.4 Built-in Dynamic Classes Section 3.6 Casting Section 3.8 ActionScript 2.0 Type Checking Gotchas Section 3.3 Compatible Types Section 3.5 Circumventing Type Checking Section 3.7 Datatype Information for Built-in Classes Section 3.9 Up Next: Creating ClassesYour Own Datatypes! Chapter 4 Classes Section 4.1 Defining Classes Section 4.2 Constructor Functions (Take 1) Section 4.4 Methods Section 4.6 Completing the Box Class Section 4.3 Properties Section 4.5 Constructor Functions (Take 2) Section 4.7 Putting Theory into Practice Chapter 5 Authoring an ActionScript 2.0 Class Section 5.1 Class Authoring Quick Start Section 5.2 Designing the ImageViewer Class Section 5.4 Using ImageViewer in a Movie Section 5.6 ImageViewer Implementation (Take 3) Section 5.3 ImageViewer Implementation (Take 1) Section 5.5 ImageViewer Implementation (Take 2) Section 5.7 Back to the Classroom Chapter 6 Inheritance Section 6.1 A Primer on Inheritance Section 6.2 Subclasses as Subtypes Section 6.3 An OOP Chat Example Section 6.5 Constructor Functions in Subclasses Section 6.7 Augmenting Built-in Classes and Objects Section 6.9 Abstract and Final Classes Not Supported Section 6.4 Overriding Methods and Properties Section 6.6 Subclassing Built-in Classes Section 6.8 The Theory of Inheritance Section 6.10 Let's Try Inheritance Chapter 7 Authoring an ActionScript 2.0 Subclass Section 7.2 The ImageViewerDeluxe Skeleton Section 7.4 Autosizing the Image Viewer Section 7.6 Moving Right Along Section 7.1 Extending ImageViewer's Capabilities Section 7.3 Adding setPosition( ) and setSize( ) Methods Section 7.5 Using ImageViewerDeluxe Chapter 8 Interfaces Section 8.1 The Case for Interfaces Section 8.3 Interface Syntax and Use Section 8.5 Up Next, Packages Section 8.2 Interfaces and Multidatatype Classes Section 8.4 Multiple Type Inheritance with Interfaces Chapter 9 Packages Section 9.1 Package Syntax Section 9.3 Package Access and the Classpath Section 9.5 Just a Little More Theory Section 9.2 Defining Packages Section 9.4 Simulating Packages in ActionScript 1.0 Chapter 10 Exceptions Section 10.1 The Exception-Handling Cycle Section 10.3 Exception Bubbling Section 10.5 Nested Exceptions Section 10.7 Limitations of Exception Handling in ActionScript 2.0 Section 10.2 Handling Multiple Types of Exceptions Section 10.4 The finally Block Section 10.6 Control Flow Changes in try/catch/finally Section 10.8 From Concepts to Code Part II: Application Development Chapter 11 An OOP Application Framework Section 11.1 The Basic Directory Structure Section 11.2 The Flash Document (.fla file) Section 11.4 The Document Timeline Section 11.6 Projects in Flash MX Professional 2004 Section 11.3 The Classes Section 11.5 The Exported Flash Movie (.swf file) Section 11.7 Let's See It in Action! Chapter 12 Using Components with ActionScript 2.0 Section 12.1 Currency Converter Application Overview Section 12.2 Preparing the Flash Document Section 12.4 Handling Component Events Section 12.3 The CurrencyConverter Class Section 12.5 Components Complete Chapter 13 MovieClip Subclasses Section 13.1 The Duality of MovieClip Subclasses Section 13.2 Avatar: A MovieClip Subclass Example Section 13.4 Issues with Nested Assets Section 13.6 Curiouser and Curiouser Section 13.3 Avatar: The Composition Version Section 13.5 A Note on MovieClip Sub-subclasses Chapter 14 Distributing Class Libraries Section 14.1 Sharing Class Source Files Section 14.2 Sharing Classes Without Sharing Source Files Section 14.3 Solving Real OOP Problems Part III: Design Pattern Examples in ActionScript 2.0 Chapter 15 Introduction to Design Patterns Section 15.1 Bring on the Patterns Chapter 16 The Observer Design Pattern Section 16.1 Implementing Observer in ActionScript 2.0 Section 16.3 Memory Management Issues with Observer Section 16.2 Logger: A Complete Observer Example Section 16.4 Beyond Observer Chapter 17 The Singleton Design Pattern Section 17.1 Implementing Singleton in ActionScript 2.0 Section 17.2 The Singleton Pattern in the Logger Class Section 17.3 Singleton Versus Class Methods and Class Properties Section 17.4 A Warning Against Singletons as Globals Section 17.5 On to User Interfaces Chapter 18 The Model-View-Controller Design Pattern Section 18.1 The General Architecture of MVC Section 18.2 A Generalized MVC Implementation Section 18.4 Further Exploration Section 18.3 An MVC Clock Chapter 19 The Delegation Event Model Section 19.1 Structure and Participants Section 19.3 Core Implementation Section 19.5 Other Event Architectures in ActionScript Section 19.2 The Flow of Logic Section 19.4 NightSky: A Delegation Event Model Example Section 19.6 From Some Place to Some OtherPlace Part IV: Appendixes Appendix A ActionScript 2.0 Language Quick Reference Section A.1 Global Properties Section A.2 Global Functions Appendix B Differences from ECMAScript Edition 4 Colophon Index Copyright © 2004 O'Reilly Media, Inc Printed in the United States of America Published by O'Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472 O'Reilly books may be purchased for educational, business, or sales promotional use Online editions are also available for most titles (http://safari.oreilly.com) For more information, contact our corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarks of O'Reilly Media, Inc Essential ActionScript 2.0, the image of a coral snake, and related trade dress are trademarks of O'Reilly Media, Inc Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and O'Reilly Media, Inc was aware of a trademark claim, the designations have been printed in caps or initial caps While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein Foreword I came to Macromedia in the summer of 2000, shortly after graduating from college, to start working as a software engineer on the Flash team In my first days at the company, the team was working tirelessly to ship Flash 5, and everyone was too busy to give me much work to do, let alone guide me in the ways of Macromedia corporate life Little did I realize that as I was learning my way around the complex C++ architecture of the Flash authoring tool, ActionScript was also beginning its own career in the web development industry Flash 5 was a landmark release for the Flash authoring tool: it brought ActionScript from an interface that required point-and-click interaction to a full-fledged scripting language based on the ECMAScript standard, with a real text editor I arrived just as the Flash team was putting real scripting power in the hands of Flash developers Over the next two releases of Flash, I participated in the continuation of that effort, first by producing the ActionScript debugger in Flash MX and, most recently, by developing the ActionScript 2.0 compiler My past few years are inextricably linked to this language, and it has contributed to my growth, just as I have contributed to its growth In the beginning, my feelings about ActionScript were similar to the feelings a lot of traditional developers have when coming to the language I found myself comfortable with its flexibility, yet frustrated with its limitations I was happy to bring features such as the debugger to life, because it helped Flash meet my own expectations of a programming environment I enjoyed working to close the gaps in Flash's capabilities, feature by feature With Flash MX, we made strides by greatly improving the code editor and by enabling users to debug their ActionScript However, ActionScript 1.0 still had one frustrating limitation that we did not address in Flash MX: it was possible to write code that employed object-oriented programming (OOP) techniques, but doing so was complex and unintuitive and not well integrated with Flash concepts like library symbols With Flash MX 2004 and ActionScript 2.0, we have arrived at yet another major landmark in ActionScript's evolution ActionScript 2.0 offers a more sophisticated syntax for the OOP constructs that ActionScript has always supported ActionScript 2.0 is easier to learn than its predecessor, and it is closer to other industry-standard programming languages, such as Java and C# It gives developers the framework needed to build and maintain large, complex applications In addition, our implementation required minimal changes to the Flash Player, meaning that ActionScript 2.0 can be exported to Flash Player 6, which was already nearly ubiquitous at the time of Flash MX 2004's release In the short time that ActionScript has been around, developers have found it to be extraordinarily powerful Flash places few constraints on the developer's access to the MovieClip hierarchy and object model, permitting them to do anything, anywhere This flexibility has stirred the creativity of our users, enabling them to grow into ActionScript and experiment with it However, the lack of structure in ActionScript 1.0 made applications difficult to scale up, leading to unwieldy projects that teams found challenging to maintain and organize It was too easy to write poor code, not to mention place code in locations almost impossible to find by others unfamiliar with the project ActionScript 2.0 aspires to address these pitfalls by encouraging a structure that all developers can adhere to and understand Moreover, the ActionScript 2.0 compiler provides developers with feedback on errors that otherwise wouldn't be found until they manifested as bugs at runtime Still, ActionScript continues to provide extensive and unique control over graphical elements We strove to ensure that ActionScript is a powerful language moving forward, without treading on the toes of already-seasoned scripters ActionScript 2.0 was also the basis for several other notable Singleton design pattern 2nd implemented in Logger class (example) implementing in ActionScript 2.0 Singleton class code singletons as globals, warning against static class methods and properties vs Slides Sound class 2nd loadSound( ) source code theft specializing a class Stage movie clip symbol, physical incarnation on Stage class standalone functions starting object-oriented application startup code in main( ) method statement block placement of curly braces states application [See application state] subject class, broadcasting to interested objects static attribute [See also class methods; class properties] class methods and properties members, properties, and methods methods 2nd methods and properties, Singleton pattern vs properties 2nd accessing through a method enumerating static properties with for-in loop inherited, bug preventing access to naming convention static class library, dynamic library vs static function libraries static methods 2nd [See also class methods; static attribute] static typing 2nd datatype information for built-in classes reasons for runtime performance and weak strict data typing String class strings ActionScript 1.0, conversions in Flash Player 7 converting numbers to converting objects to [See serialization] problems casting to String type strongly typed languages stylesheets [See CSS] CSS support for Flash Player 7 text fields TextField.StyleSheet class subclasses 2nd access to private property of superclass accessing inherited class methods/properties casting to class properties and constructor functions in problems in Flash 6 of a dynamic class MovieClip as subtypes writing [See ImageViewerDeluxe subclass] subclassing built-in classes MovieClip subclasses subclasses [See also inheritance] subinterface [See also interfaces]2nd casting to subject Observable class (example) 2nd responsibilities of, in Observer design unregistering event-listener objects before deleting subject subtype inheritance subtypes casting an object to subclasses as super keyword super operator class methods and invoking overridden instance methods invoking superclass constructor from subclass constructor member access from overridden instance method overridden class properties and overridden property access and two forms of superclasses 2nd accessing inherited class method/property via casting to Object class property overridden by subclass superinterface 2nd 3rd [See also interfaces] supertype .swc file distributing to developers .swf files automating export process bytecode case sensitivity for versions class library creating for creating movie that loads currency converter application, exporting exported to Flash Player 6's format swf file exporting imageViewer.swf and testing in Flash imageViewer.swf, exporting in Flash Player 6 format no security for code in in OOP application versions of, ActionScript and switch statement symbols, movie clip association with single AS 2.0 Class AvatarSymbol (example) building timeline and contents with component definition Linkage properties linking AvatarSymbol to Avatar class nested assets not automatically recognized by compiler properties and methods of nested assets System class System.capabilities class System.security class [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] TCP/IP connections (client/server), persistent Test Movie mode text editors (third-party), writing/editing class as files text fields CSS support for Flash 7 images in, supported in Flash Player 7 mouse wheel support in text metrics, improved (Flash Player 7) TextAnimation class, excluding from runtime loading TextField class TextField.StyleSheet class TextFieldView class (example) TextShapshot class this (keyword) class methods and constructor functions, using in managing parameter/property name conflicts MovieClip subclass methods, using with passing current object to a method redundant use of resolving property/local variable naming conflicts throw statement 2nd 3rd 4th datatypes of generated exceptions try/catch block, searching call stack for throwing an exception [See also exceptions]2nd timeline application state adding to fla file timeline changing creating labeled frames corresponding to application states placing components in timeline-based code instantiating ImageViewer to frame 15 overuse of procedural programming for type checking and toString( ) Error class 2nd Object class try/catch/finally statements 2nd catch blocks control flow changes in finally block circumstances for execution cleanup after code execution in multithreaded languages in single-threaded ActionScript Flash bug in catch block parameters handling different kinds of errors nested bug in Flash Player 7 searching call stack to match thrown exception throwing an error directly from try block try block with multiple catch blocks type casting [See casting] type checking 2nd [See also datatypes] built-in dynamic classes casting compile-time, leniency of AS2 conversion vs member selection and problems with runtime support terminology circumventing compatible types handling any datatype null and undefined datatype information for built-in classes dynamic binding vs incompatible types manual, at runtime method parameters and return values quirks and limitations of [] operator array elements global variables timeline code XML instances static typing, reasons for using strict, static, and strong typing type syntax declaring method parameter and return value datatypes declaring variable and property datatypes items applied to post-colon syntax weak static typing and type mismatch errors [See datatypes type checking] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] UIObject class, createClassObject( ) UML (Unified Modeling Language) design patterns, use in uncaught exceptions undefined datatype ActionScript 1.0, changes to in Flash Player 7 casting to missing method arguments properties returned when casting to null or undefined datatypes Unicode, using for as files uninitialized variables, null or undefined type unit testing unqualified references to classes in packages compiler resolution of, class method access and import statements, using in to properties use of unsafe casts upcasts implicit safety of updated intrinsic files user input currency conversion application management by controller in MVC pattern 2nd Uses-A relationship 2nd [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] var statement creating local variable within a method declaring variables with defining instance property variables [See also properties] assigning instance of subclass to class and instance declaring datatypes exporting to/importing from an external source local null type overriding, Java rules for referenced with slash syntax (Flash 4) slash syntax for (Flash 4) static typing undefined type version control software, managing class files versions ActionScript and Flash Player, setting for movies changes to ActionScript 1.0 in Flash Player 7 Flash naming conventions in this book Flash Player v2 components, use of Video class video games, use of object-oriented programming view, MVC [See also Model-View-Controller] ClockAnalogView and ClockDigitalView classes (example) ClockTools class (example) implementation of AbstractView class View interface responsibilities of 2nd visibility modifiers Visual Basic, multipage forms Visual Basic-style forms-based development (Screens) visual development, drag-and-drop Void datatype void operator, Void datatype vs [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] weak static typing weather-reporting application (observer pattern example) web site for this book wildcards, using to import entire package Windows systems Classes directory, location of mouse wheel support in text fields (Flash Player 7) [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] XML class XML file (exclusion file) 2nd XML instances composition vs inheritance debate type checking and XMLNode class XMLSocket class ... Macromedia Flash Team March 20 04 Preface In September 20 03, Macromedia released Flash MX 20 04, and, with it, ActionScript 2. 0a drastically enhanced version of Flash''s programming language ActionScript 2. 0 introduces a formal object-oriented... MenuBar v2 v2 v2 ProgressBar Footnote v2 2, [3] v2 RadioButton v1 v2 v2 ScrollPane v1 v2 v2 TextArea v1 v2 v2 NumericStepper TextInput v1 v2 v2 Tree [3] v2 Window [3] v2 v2 [1] Similar component available in DRK3... other hand, you''re completely new to Flash or to ActionScript, you may want to skip directly to Chapter 2 1.1 ActionScript 2. 0 Features Introduced in Flash MX 20 04 and Flash MX Professional 20 04, ActionScript 2. 0 is a major grammatical overhaul of ActionScript

Ngày đăng: 26/03/2019, 17:07