William Sanders, Chandima Cumaranatunge0596528469, 9780596528461
Table of contents :
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
Reviews
There are no reviews yet.