وبلاگ بلیان

ActionScript 3.0 Design Patterns: Object Oriented Programming Techniques (Adobe Developer Library)

معرفی کتاب «ActionScript 3.0 Design Patterns: Object Oriented Programming Techniques (Adobe Developer Library)» نوشتهٔ Sanders, William B.;Cumaranatunge, Chandima، منتشرشده توسط نشر O'Reilly Media در سال 2008. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است. «ActionScript 3.0 Design Patterns: Object Oriented Programming Techniques (Adobe Developer Library)» در دستهٔ بدون دسته‌بندی قرار دارد.

This hands-on introduction to design patterns is for experienced Flash developers ready to tackle sophisticated programming techniques with ActionScript 3.0. Now that ActionScript has been reengineered from top to bottom as a true object-oriented programming (OOP) language, reusable design patterns are an ideal way to solve common problems in Flash applications. But learning ActionScript 3.0 is a challenge for anyone without adding this extra learning curve.ActionScript 3.0 Design Patterns takes you step by step through the process, first by explaining how design patterns provide a clear road map for structuring code that actually makes OOP languages easier to learn and use. You will then learn about various types of design patterns and construct small abstract examples before trying your hand at building full-fledged working applications outlined in the book. Topics in ActionScript 3.0 Design Patterns include: Key features of ActionScript 3.0 and why it became an OOP language OOP characteristics, such as classes, abstraction, inheritance, and polymorphism The benefits of using design patterns Creational patterns, including Factory and Singleton patterns Structural patterns, including Decorator, Adapter, and Composite patterns Behavioral patterns, including Command, Observer, Strategy, State patterns How design patterns can be used in conjunction with one anotherDuring the course of the book, you will work with many examples, such as an e-business application with service options that users can select, an interface for selecting a class of products and individual products in each class, an action game application, a video record and playback application, and many more.Perfectfor Java and C++ developers coming to Flash, as well as those experienced with ActionScript 2.0 and earlier, ActionScript 3.0 Design Patterns will have you constructing truly elegant solutions for your Flash applications in no time. ActionScript 3.0 Design Patterns 1 Table of Contents 8 Preface 12 Who This Book Is For 13 How This Book Is Organized 13 What You Need to Use This Book 15 Say It Again, Sam 15 User’s Guide 16 Flex 2 developers 16 Flash Media Server 2 developers 16 Companion Tools You’ll Want 16 Conventions Used in This Book 17 Using Code Examples 18 How to Contact Us 18 Safari® Enabled 19 Acknowledgments 19 Technical Reviewers 20 Editors 21 Authors 21 Bill Sanders 21 Chandima Cumaranatunge 21 Part I 22 Object-Oriented Programming, Design Patterns, and ActionScript 3.0 24 The Pleasure of Doing Something Well 24 Sequential and Procedural Programming 25 Transition to OOP 26 MovieClip and Button scripts 26 Timeline scripts 27 Document class 27 Movie clip and button classes 28 OOP Basics 31 Abstraction 32 Abstractions in ActionScript 3.0 33 Why Abstractions Are Important 36 Encapsulation 36 Hiding Your Data from Bad Consequences 37 Private variables 38 The many meanings of interface 40 Getters and setters 41 The get and set methods 43 Using Encapsulation and Design Patterns 45 Inheritance 45 Looking at the Ancestors 45 Writing Classes for Inheritance 46 Using Interfaces and Abstract Classes in ActionScript 3.0 49 Interface constructs 49 Abstract classes and overriding inheritance 52 Why use interfaces and abstract classes? 54 Polymorphism 55 Generating Polymorphism Using an Abstract Class 55 Implementing Polymorphism with Interfaces 58 Principles of Design Pattern Development 63 Implementation 64 State 64 Client and Request 65 Program to Interfaces over Implementations 66 Managing Dependency 66 Using Complex Interfaces 68 Favor Composition 70 Doing Composition 71 Using Delegation 72 Making Composition, Inheritance, and Instantiation Work Together 77 Maintenance and Extensibility Planning 78 Planning Only for Maintenance 79 Adding Extensibility to a Plan with Granularity 80 Your Application Plan: It Ain’t You Babe 81 Using OOP and Design Patterns to Meet Client Goals 81 Choosing the Right Design Pattern 82 Achieving Better OOP Through Design Patterns 82 Part II 84 Factory Method Pattern 86 What Is the Factory Method Pattern? 86 Model of the Factory Method Pattern 87 Abstract Classes in ActionScript 3.0 89 Minimalist Example 90 Product Classes 91 Creator Classes 92 Clients 93 Hiding the Product Classes 94 Example: Print Shop 95 Product Classes: Print Jobs 96 Creator Classes: Print Centers 97 Clients 99 Print Shop Extension 99 Parameterized Factory Methods 100 Extended Example: Color Printing 101 New Product Classes 101 New Creator Classes: Integrating a Parameterized Factory Method 102 Clients 104 Parallel Class Hierarchies 104 Key OOP Concepts Used in the Factory Method Pattern 105 Example: Sprite Factory 105 Product Classes: Shape Widgets 106 Creator Classes: Shape Creators 108 Clients 110 Example: Vertical Shooter Game 111 Product Classes 112 Projectiles 112 Space ships 115 Creator Classes 118 Weapon 118 ShipCreator 120 Concrete Creator Classes 121 Clients 121 Summary 121 Singleton Pattern 122 What Is the Singleton Pattern? 122 Key Features 122 The Singleton Model 123 Key OOP Concepts Used with the Singleton Pattern 123 Creating and Using a Private Class Constructor 124 Creating a Private Class Instance 125 Minimalist Abstract Singleton 126 Instantiation with a Private Class Parameter 127 A Singleton Instantiation Method 129 One Instance and Different References 130 When to Use the Singleton Pattern 133 A Single Alert Message 134 Just One Tune at a Time 137 Using Multiple References in a Shopping Cart 142 Summary 146 Part III 148 Decorator Pattern 150 What Is the Decorator Pattern? 150 Key Features 151 The Decorator Model 152 Key OOP Concepts Used with the Decorator Pattern 153 Unwanted Inheritance 153 Wrapping Responsibilities 154 Flexibility and Adaptability 155 Minimalist Abstract Decorator 156 Abstract Component Class 156 Abstract Decorator Class 157 Concrete Decorations 159 Wrapping Up 160 Applying a Simple Decorator Pattern in Flash: PaperDoll 162 Setting Up the Component Class 162 Decorator Class: Dressing the Dolls 162 The Concrete Classes 163 Concrete component class 163 Concrete decorator classes 164 Implementing the Paper Doll Decorator 166 Decorating with Deadly Sins and Heavenly Virtues 169 Adding Properties and Methods 170 Multiple Concrete Components 170 Decorating with Multiple Properties 172 Multiple Method Concrete Decorations 172 The Good and Evil Concrete Decorators 174 Heavenly virtues 174 Deadly sins 178 Implementing the Good and Evil Decorator 181 Dual implementation 181 Charting souls 183 Dynamic Selection of Concrete Components and Decorations: A Hybrid Car Dealership 185 Setting Up the Hybrid Car Components 186 Auto abstract component 186 Hybrid car classes concrete component 187 Using Auto Options as Decorators 188 The options abstract decorator 188 The options concrete decorators 189 Setting Up the User Interface 191 Creating the document and setting the stage 195 Implementing the concrete components and their decorators 196 Summary 197 Adapter Pattern 198 What Is the Adapter Pattern? 198 A Design Pattern for Potty Training 198 Key Features of the Adapter Pattern 199 Object and Class Adapters 200 Object Adapters 200 Minimalist example of an object adapter 200 Using a parameterized adapter class 202 Class Adapters 202 Minimalist example of a class adapter 203 Key OOP Concepts in the Adapter Pattern 206 Object and Class Adapters Compared 206 Example: Car Steering Adapter 206 The Existing Class 207 Interface Conversion 209 The original interface 209 The new context 210 The new interface 210 The Adapter Class 211 The Client 212 Extended Example: Steering the Car Using a Mouse 214 Example: List Display Adapter 215 The Existing Class 216 Interface Conversion 216 The Adapter Class 217 The Client 219 Extended Example: Displaying the O’Reilly New Books List 220 Summary 224 Composite Pattern 225 What Is the Composite Pattern? 225 Key Features of the Composite Pattern 228 Minimalist Example of a Composite Pattern 228 Accessing Child Nodes 232 Removing Nodes 233 Creating a parent reference 233 Implementing the remove method 234 Building and Manipulating a Composite Structure 236 Key OOP Concepts in the Composite Pattern 238 Example: Music Playlists 238 Queuing Songs to Play in Sequence 240 Building Composite Playlists 242 Example: Animating Composite Objects Using Inverse Kinematics 243 Using Inverse Kinematics 244 Creating Component and Composite Nodes for the Snake 244 Building the Snake Head 246 Controlling the Snake 247 Moving a Kinematic Pair 249 Building the Body and Tail Segments 250 Building the Composite Snake 253 Using Flash’s Built-in Composite Structure: theDisplayList 254 Creating a Composite Airplane 255 Developing the Component and Composite Classes for the Airplane 255 Creating the Fuselage, Wings, and Engines 258 Building the Composite Structure 259 Calculating the Total Weight of the Airplane 261 Modifying Components to Reflect Damage 262 Calculating Total Damage to the Airplane 263 Summary 264 Part IV 266 Command Pattern 268 What Is the Command Pattern? 268 Mom Needs to Issue Some Commands 269 Key Features of the Command Pattern 271 Class Diagram of the Command Pattern 271 Minimalist Example of a Command Pattern 272 The Command Interface 272 The Concrete Command 272 The Receiver 273 The Invoker 273 The Client 274 Setting a Trigger to Invoke the Command 275 Key OOP Concepts in the Command Pattern 276 Minimalist Example: Macro Commands 276 The Macro Command Interface 276 Two Concrete Subcommands 277 The Concrete Macro Command 278 A Macro Command Object Created from the Client 279 Example: Number Manipulator 279 A Utility Button Class 280 Triggering an Invoker by Button Clicks 281 The Increment and Decrement Commands 283 The Client 284 Extended Example: Sharing Command Objects 285 Triggering an Invoker by Key Presses 285 Sharing Command Objects from the Client 286 Extended Example: Implementing Undo 287 An Abstract Interface for Commands 287 Concrete Commands that Implement Undo 288 Undoable Commands Assigned from the Client 290 Example: Podcast Radio 291 What Is a Podcast? 291 Creating a Package with Utility Classes 292 Creating a Command to Play a Podcast 293 Developing the Radio Receiver 293 Push Button Invokers for the Radio 295 The Client Assigns Podcasts to Push Buttons 296 Extended Example: Dynamic Command Object Assignment 297 A Context Sensitive Invoker 297 Commands to Dynamically Assign Command Objects 299 Dynamic Command Assignment Setup from the Client 300 Summary 302 Observer Pattern 303 What Is the Observer Pattern? 303 Key Features 304 The Observer Model 305 Key OOP Concepts Used with the Observer Pattern 306 Choose the Interface 306 Object Composition 309 Minimalist Abstract Observer 310 Subject Interface 311 Observer Interface 311 Concrete Subject 312 Concrete Observer 313 Working the Observer 314 Example: Adding States and Identifying Users 315 Multiple States 316 Who Are You? 317 Updated Observer 318 Playing the Bugle 321 Dynamically Changing States 323 Recording a Space Battle 323 Giving More Work to the Concrete Classes 324 Launching the Space Battle 327 Setting up the Flash document 327 Building the spaceships 327 Building the weapons 328 Building the Android space station and beam 329 Writing a Change Handler 331 Example: Working with Different Data Displays 338 The Output Designer 338 The Concrete Classes and a Double Implementation 340 The Data Design Classes 341 UIList component 341 Bar chart display 343 The line graph 345 Pulling All the Elements Together 347 Summary 351 Template Method Pattern 352 What Is the Template Method Pattern? 352 Key Features 354 The Template Method Model 355 Key OOP Concepts Used with the Template Method 356 Why Inheritance and Not Composition? 356 Abstract Functions and Override Flexibility 357 Consider Variation 358 The Hollywood Principle 358 Minimalist Example: Abstract Template Method 359 Bare Bones Template Method 359 Testing Templates 361 Employing Flexibility in the Template Method 362 Selecting and Playing Sound and Video 365 Setting Up the Format 365 Not-So-Concrete Concrete Classes 367 The Detail Classes 368 Playing the Media 370 Hooking It Up 372 When to Hook? 373 The Hook as a Lonely Repairman 373 Baja Flight with a Hook 373 Summary 377 State Pattern 378 Design Pattern to Create a State Machine 378 Key Features 378 The State Model 379 Transitions 380 Triggers 380 State design structure 381 Key OOP Concepts Used with the State Pattern 381 Minimalist Abstract State Pattern 382 Managing All Those States: Hardworking Context Class 384 Creating a context class 384 Completing and testing the abstract state machine 385 Video Player Concrete State Application 388 Expanding the State Design: Adding States 395 Adding the Pause State to the Statechart 395 Adding New Behaviors 396 Adding More States and Streaming Capabilities 403 Setting Up Your ActionScript 3.0 Script for FMS2 403 The Adaptable States 404 Summary 418 Strategy Pattern 419 What is the Strategy Pattern? 419 Key Features 420 The Strategy Model 420 Key OOP Concepts Used with the Strategy Pattern 421 Encapsulating Variation 421 Unencapsulated version (pseudocode) 421 Encapsulated algorithms (pseudocode) 422 Using Delegation and Delegates 422 Minimalist Abstract State Pattern 423 Using Delegation with the Context 424 Adding a Strategy 424 Details of the Strategy 424 More Delegation in a Concrete Context 425 Pulling All the Parts Together 425 Adding More Concrete Strategies and Concrete Contexts 427 The Clowns 427 The Trick Interface and Implementations 428 The Skits Interface and Implementations 430 Here Come the Clowns! 431 Additional Clown Functionality 432 Adding a new clown 432 Adding a new trick 433 Revising clown college 433 Tricks and Skits Reorganization: Clown Planning 435 Working with String Strategies 435 Contexts for String Strategies 437 String Strategies 438 Checking strategies 439 Sort strategies 440 Support Classes 441 String Strategy Test 442 Summary 444 Part V 446 Model-View-Controller Pattern 448 What Is the Model-View-Controller (MVC) Pattern? 448 Model 449 View 449 Controller 449 Communication Between the MVC Elements 449 Embedded Patterns in the MVC 451 Minimalist Example of an MVC Pattern 452 Model as a Concrete Subject in an Observer Pattern 452 The EventDispatcher class in ActionScript 3.0 452 The model 453 Controller as a Concrete Strategy in a Strategy Pattern 454 The controller 454 View as a Concrete Observer in an Observer Pattern and Context in a Strategy Pattern 455 Building the MVC Triad 456 Nested Views as Leaves and Nodes of a Composite Pattern 457 Component and composite views 458 Creating nested views 460 Building the Nested View Structure 462 Key Features of the MVC Pattern 463 Key OOP Concepts in the MVC Pattern 464 Example: Weather Maps 464 The Model 464 The Controller 467 The Views 468 Combo box view 469 Map view 470 Building the MVC Triad 471 Setting the Model to Self-Update 472 Extended Example: Infrared Weather Maps 472 Adding a New Model 473 Adding a New Controller 475 Adding a New View 475 Building the MVC Triad 477 Example: Cars 478 The Model 479 The Controller 481 The Views 482 Building the Car 483 Custom Views 484 Direction Gauge View 485 GPS View 485 Adding the Custom Views 486 Adding a Chase Car 487 Summary 489 Symmetric Proxy Pattern 490 Simultaneous Game Moves and Outcomes 490 The Player 491 The Referee 492 The Internet, Proxies, and Players 493 The Symmetric Proxy Pattern 494 Key Features 495 The cell 495 The proxy 495 Key OOP Concepts Used with the Symmetric Proxy 496 Communication Flexibility 497 Game Flexibility 497 The Player Interface 498 The Referee 499 Methods 501 Template Method 502 RPS Subclass 502 Information Shared Over the Internet 504 Player-Proxy Classes 507 Move Making 512 Event to move 512 Dual moves 513 Proxy move 513 Referee object 513 Player 2 Changes 514 Classes and Document Files Support 515 Dynamic Output Text Fields 515 Button Controls 516 The Flash File and Connection Movie Clip 517 Summary 519 Index 520 ActionScript 3.0 Design Patterns......Page 1 Table of Contents......Page 8 Preface......Page 12 How This Book Is Organized......Page 13 Say It Again, Sam......Page 15 Companion Tools You’ll Want......Page 16 Conventions Used in This Book......Page 17 How to Contact Us......Page 18 Acknowledgments......Page 19 Technical Reviewers......Page 20 Chandima Cumaranatunge......Page 21 Part I......Page 22 The Pleasure of Doing Something Well......Page 24 Sequential and Procedural Programming......Page 25 MovieClip and Button scripts......Page 26 Document class......Page 27 Movie clip and button classes......Page 28 OOP Basics......Page 31 Abstraction......Page 32 Abstractions in ActionScript 3.0......Page 33 Encapsulation......Page 36 Hiding Your Data from Bad Consequences......Page 37 Private variables......Page 38 The many meanings of interface......Page 40 Getters and setters......Page 41 The get and set methods......Page 43 Looking at the Ancestors......Page 45 Writing Classes for Inheritance......Page 46 Interface constructs......Page 49 Abstract classes and overriding inheritance......Page 52 Why use interfaces and abstract classes?......Page 54 Generating Polymorphism Using an Abstract Class......Page 55 Implementing Polymorphism with Interfaces......Page 58 Principles of Design Pattern Development......Page 63 State......Page 64 Client and Request......Page 65 Managing Dependency......Page 66 Using Complex Interfaces......Page 68 Favor Composition......Page 70 Doing Composition......Page 71 Using Delegation......Page 72 Making Composition, Inheritance, and Instantiation Work Together......Page 77 Maintenance and Extensibility Planning......Page 78 Planning Only for Maintenance......Page 79 Adding Extensibility to a Plan with Granularity......Page 80 Using OOP and Design Patterns to Meet Client Goals......Page 81 Achieving Better OOP Through Design Patterns......Page 82 Part II......Page 84 What Is the Factory Method Pattern?......Page 86 Model of the Factory Method Pattern......Page 87 Abstract Classes in ActionScript 3.0......Page 89 Minimalist Example......Page 90 Product Classes......Page 91 Creator Classes......Page 92 Clients......Page 93 Hiding the Product Classes......Page 94 Example: Print Shop......Page 95 Product Classes: Print Jobs......Page 96 Creator Classes: Print Centers......Page 97 Print Shop Extension......Page 99 Parameterized Factory Methods......Page 100 New Product Classes......Page 101 New Creator Classes: Integrating a Parameterized Factory Method......Page 102 Parallel Class Hierarchies......Page 104 Example: Sprite Factory......Page 105 Product Classes: Shape Widgets......Page 106 Creator Classes: Shape Creators......Page 108 Clients......Page 110 Example: Vertical Shooter Game......Page 111 Projectiles......Page 112 Space ships......Page 115 Weapon......Page 118 ShipCreator......Page 120 Summary......Page 121 Key Features......Page 122 Key OOP Concepts Used with the Singleton Pattern......Page 123 Creating and Using a Private Class Constructor......Page 124 Creating a Private Class Instance......Page 125 Minimalist Abstract Singleton......Page 126 Instantiation with a Private Class Parameter......Page 127 A Singleton Instantiation Method......Page 129 One Instance and Different References......Page 130 When to Use the Singleton Pattern......Page 133 A Single Alert Message......Page 134 Just One Tune at a Time......Page 137 Using Multiple References in a Shopping Cart......Page 142 Summary......Page 146 Part III......Page 148 What Is the Decorator Pattern?......Page 150 Key Features......Page 151 The Decorator Model......Page 152 Unwanted Inheritance......Page 153 Wrapping Responsibilities......Page 154 Flexibility and Adaptability......Page 155 Abstract Component Class......Page 156 Abstract Decorator Class......Page 157 Concrete Decorations......Page 159 Wrapping Up......Page 160 Decorator Class: Dressing the Dolls......Page 162 Concrete component class......Page 163 Concrete decorator classes......Page 164 Implementing the Paper Doll Decorator......Page 166 Decorating with Deadly Sins and Heavenly Virtues......Page 169 Multiple Concrete Components......Page 170 Multiple Method Concrete Decorations......Page 172 Heavenly virtues......Page 174 Deadly sins......Page 178 Dual implementation......Page 181 Charting souls......Page 183 Dynamic Selection of Concrete Components and Decorations: A Hybrid Car Dealership......Page 185 Auto abstract component......Page 186 Hybrid car classes concrete component......Page 187 The options abstract decorator......Page 188 The options concrete decorators......Page 189 Setting Up the User Interface......Page 191 Creating the document and setting the stage......Page 195 Implementing the concrete components and their decorators......Page 196 Summary......Page 197 A Design Pattern for Potty Training......Page 198 Key Features of the Adapter Pattern......Page 199 Minimalist example of an object adapter......Page 200 Class Adapters......Page 202 Minimalist example of a class adapter......Page 203 Example: Car Steering Adapter......Page 206 The Existing Class......Page 207 The original interface......Page 209 The new interface......Page 210 The Adapter Class......Page 211 The Client......Page 212 Extended Example: Steering the Car Using a Mouse......Page 214 Example: List Display Adapter......Page 215 Interface Conversion......Page 216 The Adapter Class......Page 217 The Client......Page 219 Extended Example: Displaying the O’Reilly New Books List......Page 220 Summary......Page 224 What Is the Composite Pattern?......Page 225 Minimalist Example of a Composite Pattern......Page 228 Accessing Child Nodes......Page 232 Creating a parent reference......Page 233 Implementing the remove method......Page 234 Building and Manipulating a Composite Structure......Page 236 Example: Music Playlists......Page 238 Queuing Songs to Play in Sequence......Page 240 Building Composite Playlists......Page 242 Example: Animating Composite Objects Using Inverse Kinematics......Page 243 Creating Component and Composite Nodes for the Snake......Page 244 Building the Snake Head......Page 246 Controlling the Snake......Page 247 Moving a Kinematic Pair......Page 249 Building the Body and Tail Segments......Page 250 Building the Composite Snake......Page 253 Using Flash’s Built-in Composite Structure: theDisplayList......Page 254 Developing the Component and Composite Classes for the Airplane......Page 255 Creating the Fuselage, Wings, and Engines......Page 258 Building the Composite Structure......Page 259 Calculating the Total Weight of the Airplane......Page 261 Modifying Components to Reflect Damage......Page 262 Calculating Total Damage to the Airplane......Page 263 Summary......Page 264 Part IV......Page 266 What Is the Command Pattern?......Page 268 Mom Needs to Issue Some Commands......Page 269 Class Diagram of the Command Pattern......Page 271 The Concrete Command......Page 272 The Invoker......Page 273 The Client......Page 274 Setting a Trigger to Invoke the Command......Page 275 The Macro Command Interface......Page 276 Two Concrete Subcommands......Page 277 The Concrete Macro Command......Page 278 Example: Number Manipulator......Page 279 A Utility Button Class......Page 280 Triggering an Invoker by Button Clicks......Page 281 The Increment and Decrement Commands......Page 283 The Client......Page 284 Triggering an Invoker by Key Presses......Page 285 Sharing Command Objects from the Client......Page 286 An Abstract Interface for Commands......Page 287 Concrete Commands that Implement Undo......Page 288 Undoable Commands Assigned from the Client......Page 290 What Is a Podcast?......Page 291 Creating a Package with Utility Classes......Page 292 Developing the Radio Receiver......Page 293 Push Button Invokers for the Radio......Page 295 The Client Assigns Podcasts to Push Buttons......Page 296 A Context Sensitive Invoker......Page 297 Commands to Dynamically Assign Command Objects......Page 299 Dynamic Command Assignment Setup from the Client......Page 300 Summary......Page 302 What Is the Observer Pattern?......Page 303 Key Features......Page 304 The Observer Model......Page 305 Choose the Interface......Page 306 Object Composition......Page 309 Minimalist Abstract Observer......Page 310 Observer Interface......Page 311 Concrete Subject......Page 312 Concrete Observer......Page 313 Working the Observer......Page 314 Example: Adding States and Identifying Users......Page 315 Multiple States......Page 316 Who Are You?......Page 317 Updated Observer......Page 318 Playing the Bugle......Page 321 Recording a Space Battle......Page 323 Giving More Work to the Concrete Classes......Page 324 Building the spaceships......Page 327 Building the weapons......Page 328 Building the Android space station and beam......Page 329 Writing a Change Handler......Page 331 The Output Designer......Page 338 The Concrete Classes and a Double Implementation......Page 340 UIList component......Page 341 Bar chart display......Page 343 The line graph......Page 345 Pulling All the Elements Together......Page 347 Summary......Page 351 What Is the Template Method Pattern?......Page 352 Key Features......Page 354 The Template Method Model......Page 355 Why Inheritance and Not Composition?......Page 356 Abstract Functions and Override Flexibility......Page 357 The Hollywood Principle......Page 358 Bare Bones Template Method......Page 359 Testing Templates......Page 361 Employing Flexibility in the Template Method......Page 362 Setting Up the Format......Page 365 Not-So-Concrete Concrete Classes......Page 367 The Detail Classes......Page 368 Playing the Media......Page 370 Hooking It Up......Page 372 Baja Flight with a Hook......Page 373 Summary......Page 377 Key Features......Page 378 The State Model......Page 379 Triggers......Page 380 Key OOP Concepts Used with the State Pattern......Page 381 Minimalist Abstract State Pattern......Page 382 Creating a context class......Page 384 Completing and testing the abstract state machine......Page 385 Video Player Concrete State Application......Page 388 Adding the Pause State to the Statechart......Page 395 Adding New Behaviors......Page 396 Setting Up Your ActionScript 3.0 Script for FMS2......Page 403 The Adaptable States......Page 404 Summary......Page 418 What is the Strategy Pattern?......Page 419 The Strategy Model......Page 420 Unencapsulated version (pseudocode)......Page 421 Using Delegation and Delegates......Page 422 Minimalist Abstract State Pattern......Page 423 Details of the Strategy......Page 424 Pulling All the Parts Together......Page 425 The Clowns......Page 427 The Trick Interface and Implementations......Page 428 The Skits Interface and Implementations......Page 430 Here Come the Clowns!......Page 431 Adding a new clown......Page 432 Revising clown college......Page 433 Working with String Strategies......Page 435 Contexts for String Strategies......Page 437 String Strategies......Page 438 Checking strategies......Page 439 Sort strategies......Page 440 Support Classes......Page 441 String Strategy Test......Page 442 Summary......Page 444 Part V......Page 446 What Is the Model-View-Controller (MVC) Pattern?......Page 448 Communication Between the MVC Elements......Page 449 Embedded Patterns in the MVC......Page 451 The EventDispatcher class in ActionScript 3.0......Page 452 The model......Page 453 The controller......Page 454 View as a Concrete Observer in an Observer Pattern and Context in a Strategy Pattern......Page 455 Building the MVC Triad......Page 456 Nested Views as Leaves and Nodes of a Composite Pattern......Page 457 Component and composite views......Page 458 Creating nested views......Page 460 Building the Nested View Structure......Page 462 Key Features of the MVC Pattern......Page 463 The Model......Page 464 The Controller......Page 467 The Views......Page 468 Combo box view......Page 469 Map view......Page 470 Building the MVC Triad......Page 471 Extended Example: Infrared Weather Maps......Page 472 Adding a New Model......Page 473 Adding a New View......Page 475 Building the MVC Triad......Page 477 Example: Cars......Page 478 The Model......Page 479 The Controller......Page 481 The Views......Page 482 Building the Car......Page 483 Custom Views......Page 484 GPS View......Page 485 Adding the Custom Views......Page 486 Adding a Chase Car......Page 487 Summary......Page 489 Simultaneous Game Moves and Outcomes......Page 490 The Player......Page 491 The Referee......Page 492 The Internet, Proxies, and Players......Page 493 The Symmetric Proxy Pattern......Page 494 The proxy......Page 495 Key OOP Concepts Used with the Symmetric Proxy......Page 496 Game Flexibility......Page 497 The Player Interface......Page 498 The Referee......Page 499 Methods......Page 501 RPS Subclass......Page 502 Information Shared Over the Internet......Page 504 Player-Proxy Classes......Page 507 Event to move......Page 512 Referee object......Page 513 Player 2 Changes......Page 514 Dynamic Output Text Fields......Page 515 Button Controls......Page 516 The Flash File and Connection Movie Clip......Page 517 Summary......Page 519 Index......Page 520 Now that ActionScript is reengineered from top to bottom as a true object-oriented programming (OOP) language, reusable design patterns are an ideal way to solve common problems in Flash and Flex applications. If you're an experienced Flash or Flex developer ready to tackle sophisticated programming techniques with ActionScript 3.0, this hands-on introduction to design patterns is the book you need. ActionScript 3.0 Design Patterns takes you step by step through the process, first by explaining how design patterns provide a clear road map for structuring code that actually makes OOP languages easier to learn and use. You then learn about various types of design patterns and construct small abstract examples before trying your hand at building full-fledged working applications outlined in the book. Topics in ActionScript 3.0 Design Patterns include: Key features of ActionScript 3.0 and why it became an OOP language OOP characteristics, such as classes, abstraction, inheritance, and polymorphism The benefits of using design patterns Creational patterns, including Factory and Singleton patterns Structural patterns, including Decorator, Adapter, and Composite patterns Behavioral patterns, including Command, Observer, Strategy, and State patterns Multiple design patterns, including Model-View-Controller and Symmetric Proxy designs During the course of the book, you'll work with examples of increasing complexity, such as an e-business application with service options that users can select, an interface for selecting a class of products and individual products in each class, an action game application, a video record and playback application, and many more. Whether you're coming to Flash and Flex from Java or C++, or have experience with ActionScript 2.0, ActionScript 3.0 Design Patterns will have you constructing truly elegant solutions for your Flash and Flex applications in no time. "Now that ActionScript is reengineered from top to bottom as a true object-oriented programming (OOP) language, reusable design patterns are an ideal way to solve common problems in Flash and Flex applications. If you're an experienced Flash or Flex developer ready to tackle sophisticated programming techniques with ActionScript 3.0, this hands-on introduction to design patterns is the book you need." "ActionScript 3.0 Design Patterns takes you step by step through the process, first by explaining how design patterns provide a clear roadmap for structuring code that actually makes OOP languages easier to learn and use. You then learn about various types of design patterns and construct small abstract examples before trying your hand at building the full-fledged working applications outlined in this book." "During the course of the book, you'll work with examples of increasing complexity, such as an e-business application with service options that users can select, an interface for selecting a class of products and individual products in each class, an action game application, a video record and playback application, and many more. Whether you're coming to Flash and Flex from Java or C++, or have experience with ActionScript 2.0, ActionScript 3.0 Design Patterns will have you constructing truly elegant solutions for your Flash and Flex applications in no time."--Jacket
دانلود کتاب ActionScript 3.0 Design Patterns: Object Oriented Programming Techniques (Adobe Developer Library)