Your Federal Quarterly Tax Payments are due April 15th Get Help Now >>

Part I Introduction to Flex 3 by zzz22140

VIEWS: 111 PAGES: 31

									                                                               Contents
                    Introduction                                          lv

                    Part I: Introduction to Flex 3                        1
                    Chapter 1: Why Flex?                                   3
                      What Is Flex?                                       3
                      What Is an RIA?                                     4
                        Clarifying the Competition                        6
                      For the Love of Flex                                7
                        Bursting Myths about Flash and Flex               7
                        10 Reasons to Love Flex                          12
                      Summary                                            15

                    Chapter 2: The Flex 3 Ecosystem                      17
                      A (Not So) Brief History of Flex                   17
                      The Adobe Flex 3 Ecosystem                         19
                         Runtimes                                        19
                         Languages                                       27
                         Frameworks and APIs                             30
                         Data Communications                             32
                         Servers                                         34
                      The Adobe Flex RIA Process Flow                    35
                         Design and Development                          36
                         Execution                                       37
                         Communication                                   37
                         Infrastructure                                  38
                      Future Additions to the Flex Ecosystem             38
                      Summary                                            39

                    Chapter 3: ActionScript 3.0 Fundamentals            41
                      Core Language Concepts                             41
                        Basic Syntax                                     42
                        Reserved Keywords                                43
                        Variables and Data types                         44
                      Control Structures                                 44
                        Conditional Statements                           44
                        Loops                                            46




23642ftoc.indd 19                                                   5/2/09 4:16:21 PM
     Contents
          Using Classes and Data types                47
            Value Types                               47
            Numbers                                   48
            Strings                                   49
            Arrays                                    50
            Vectors                                   52
            Objects                                   53
            Casting                                   54
            Introspection                             55
          Object-Oriented Programming                 57
            The Class Object                          58
            Packages and Classes                      58
            Class Attributes                          59
            Class Members                             59
            Interfaces and Inheritance                64
          Summary                                     65

     Chapter 4: Using ActionScript 3.0                67
          The Flash Platform Framework                67
          Display Programming                         68
             Understanding the Display Architecture   68
          The Event Model                             69
             Event Classes and Types                  69
             Event Process                            70
             Event Flow                               71
             The EventDispatcher Class                72
          The Flash Player APIs                       73
             The Display API                          74
             The Flash AIR APIs                       78
             Flash 10 APIs                            79
          Summary                                     83

     Chapter 5: Introduction to Flex Builder 3        85
          Getting Started with Flex Builder           85
            Flex Builder and Eclipse                  86
            Learning Flex and Getting Help            87
          The Flex 3 Workbench                        90
            Workspaces                                91
            Editors                                   93
            Views                                     93
            Perspectives                              94



     xx



23642ftoc.indd 20                                          5/2/09 4:16:21 PM
                                                              Contents
                      What’s New in Flex Builder 3                   98
                        New Wizards                                  98
                        Design Mode Enhancements                     98
                        Development Enhancements                     99
                        CS3 Suite Integration                        99
                      Summary                                       100

                    Part II: Developing with Flex 3               101
                    Chapter 6: Using Flex Builder 3                103
                      The Flex Compilation Process                  103
                        Development                                 104
                        Compilation                                 105
                        Publishing                                  106
                      About Projects                                106
                        Creating New Projects                       107
                      Creating a Flex Application                   108
                        Creating a Flex Project                     108
                        Using Design Mode                           111
                        Using Data Binding                          117
                        Using Triggers and Effects                  118
                        Compiling Your Application                  119
                      Creating an ActionScript Application          120
                        Creating an ActionScript Project            120
                        Comparing File Sizes                        123
                      The (Undocumented) [SWF] Metadata Tag         123
                        [SWF] Metadata Properties                   124
                      Summary                                       125

                    Chapter 7: MXML Fundamentals                   127
                      Language Principles                           127
                        MXML Is XML                                 127
                        Naming Conventions                          128
                        MXML Syntax                                 128
                        Display Hierarchy                           129
                        MXML Namespaces                             129
                      Using MXML                                    133
                        MXML Tags                                   133
                        MXML Properties                             135
                        Using MXML and CSS                          139
                        Using MXML and ActionScript                 141
                      Summary                                       148


                                                                      xxi



23642ftoc.indd 21                                                5/2/09 4:16:21 PM
     Contents
     Chapter 8: Developing with Flex Builder 3                  149
         Managing Projects                                      149
           Project Properties                                   149
           Exporting Projects                                   154
           Importing Projects                                   154
           Navigating Projects                                  157
         Building Applications                                  164
           Creating a Debug Release                             164
           Creating an Export Release                           165
           Enabling Source View                                 167
         Language Intelligence                                  170
           Code Editing                                         170
           Code Preferences                                     173
           Code Introspection                                   173
           Keyboard Shortcuts                                   176
         Summary                                                178

     Chapter 9: Customizing Flex Builder 3                      179
         Optimizing Flex Builder Performance                    179
           Project Development Best Practices                   179
           Eclipse Performance Management                       181
         Customizing the Workbench                              186
           Editing the Workspaces List                          186
           Using Custom Shortcuts                               188
           Layouts for Productivity                             189
           Managing Workspace Preferences                       190
         Using Code Repositories in Flex Builder                190
           Using the Local History                              191
           Subclipse for Subversion Source Management           192
         Summary                                                214

     Part III: Working with Components                          215
     Chapter 10: The Component Life Cycle and Class Hierarchy   217
         The Role of Flash in Flex Applications                 217
         The Flex Framework Life Cycle                          218
            Frame-by-Frame                                      218
            The Life Cycle                                      220
         Flex Class Hierarchy                                   222
            Flash and Flex Class Packages                       222
            UIComponent                                         222


     xxii



23642ftoc.indd 22                                                     5/2/09 4:16:22 PM
                                                                                    Contents
                        Container Classes                                                 224
                        List Classes                                                      225
                        Formatters, Validators, and Collection Classes                    226
                        Framework Functions and Events                                    228
                      Summary                                                             229

                    Chapter 11: Using Data Binding and Events                            231
                      Using {Curly Braces}                                                231
                      [Bindable] Metadata                                                 235
                      Events                                                              236
                         Capture Phase                                                    236
                         Target Phase                                                     237
                         Bubbling Phase                                                   238
                      Stopping Events                                                     238
                      Event Listeners                                                     239
                         Using MXML                                                       240
                         Using ActionScript                                               240
                      Event Types                                                         241
                      Custom Events                                                       241
                         Creating Custom Events                                           241
                         [Event] Metadata                                                 242
                         Strategies for Using Custom Events                               243
                      Summary                                                             244

                    Chapter 12: User Interface Controls and Containers                   245
                      Static Controls                                                     245
                         mx.controls.Label and mx.controls.Text                           245
                         mx.controls.Image                                                246
                         mx.controls.SWFLoader                                            247
                         mx.controls.HRule and mx.controls.VRule                          247
                         mx.controls.ProgressBar                                          248
                      Input Controls                                                      248
                         mx.controls.Button and mx.controls.LinkButton                    249
                         mx.controls.TextInput and mx.controls.TextArea                   249
                         mx.controls.NumericStepper                                       250
                         mx.controls.DateChooser and mx.controls.DateField                250
                         mx.controls.CheckBox                                             251
                         mx.controls.ComboBox                                             252
                         mx.controls.RadioButton and mx.controls.RadioButtonGroup         252
                         mx.controls.HSlider and mx.controls.VSlider                      253
                         mx.controls.RichTextEditor                                       254



                                                                                          xxiii



23642ftoc.indd 23                                                                      5/2/09 4:16:22 PM
     Contents
            mx.controls.PopUpButton                                               254
            mx.controls.PopUpMenuButton                                           255
            mx.controls.ColorPicker                                               256
         Layout Containers                                                        256
            mx.containers.Canvas                                                  256
            mx.container.VBox and mx.container.HBox                               257
            mx.containers.HDividedBox and mx.containers.VDividedBox               258
            mx.core.Application, mx.containers.Panel, mx.containers.TitleWindow   259
            mx.containers.Grid                                                    260
            mx.containers.Tile                                                    261
            mx.containers.Form                                                    262
            mx.containers.ControlBar                                              263
            mx.containers.ApplicationControlBar                                   264
         Navigation Components                                                    264
            creationPolicy                                                        264
            mx.containers.Accordion                                               265
            mx.containers.TabNavigator                                            265
            mx.containers.ViewStack                                               266
            mx.controls.LinkBar                                                   267
            mx.controls.TabBar                                                    267
            mx.containers.MenuBar and mx.controls.Menu                            268
            mx.controls.ButtonBar and mx.controls.ToggleButtonBar                 269
         List Controls                                                            270
         Summary                                                                  270

     Chapter 13: Layout Strategies                                                271
         Coordinate Positioning                                                   271
         Constraint Positioning                                                   272
         Positioning by Percentage                                                273
         Positioning by Alignment                                                 274
         Advanced Constraints                                                     275
           ConstraintColumns                                                      276
           ConstraintRows                                                         277
           Constraints in ActionScript                                            278
           Constraint Sizes                                                       278
         Using includeInLayout                                                    279
         Performance Considerations                                               280
         Summary                                                                  280

     Chapter 14: User Interface Integration                                       281
         Creating Forms                                                           281
           Submitting Form Content                                                284

     xxiv



23642ftoc.indd 24                                                                       5/2/09 4:16:22 PM
                                                                                                Contents
                        Building Forms with Flex Builder Design View                                  285
                        Setting the defaultButton on the Form                                         286
                      Customizing Tooltips                                                            286
                        Custom ToolTips                                                               286
                      Creating Pop-Ups                                                                288
                        Alerts                                                                        289
                        Using the PopUpManager                                                        291
                        Interacting with Pop-Ups                                                      293
                      Custom Cursors                                                                  295
                        Cursor Management                                                             295
                        Busy Cursors                                                                  295
                        Hand Cursors                                                                  296
                        Custom Cursors                                                                296
                      Summary                                                                         297

                    Chapter 15: Getting Started with AIR                                             299
                      What Does AIR Provide?                                                          299
                        Why Use AIR?                                                                  300
                        Applications That Can Be Built with AIR                                       300
                        Requirements for AIR                                                          301
                      Building an AIR Application                                                     302
                        The IntroToAIR.mxml File                                                      303
                        The IntroToAIR-app.xml Descriptor File                                        304
                      The AIR Configuration File                                                      306
                      Building an AIR Application Part II                                             311
                        Modifying the IntroToAIR.mxml Window                                          311
                        The MainWindow.mxml File                                                      313
                        The IntroToAIR-app.xml Descriptor File                                        314
                      Summary                                                                         316

                    Part IV: Advanced Component Development                                         317
                    Chapter 16: Custom ActionScript Components                                       319
                      Company Logo Example                                                            320
                        UIComponent and IUIComponent                                                  320
                        CompanyLogo.as                                                                321
                      Component Structure                                                             323
                        Component Properties and the Flex Framework Life Cycle                        323
                        Invalidate Functions                                                          324
                        Adding Child Components                                                       325
                        Using invalidateProperties() and Applying Properties to the Component         326
                        Measuring Components                                                          327


                                                                                                       xxv



23642ftoc.indd 25                                                                                  5/2/09 4:16:22 PM
     Contents
           Component Layout                                     328
           Selecting the Base Class for Your Component          330
           Sizing Child Components                              332
         RockerSwitch Example                                   333
         Summary                                                341

     Chapter 17: Custom MXML Components                         343
         MXML Versus ActionScript Components                    343
         Customizing the Layout                                 345
           Overriding updateDisplayList()                       345
           Overriding layoutChrome()                            346
           Setting Up Metadata Tags                             348
         Creating Template Components                           348
           DefaultProperty Meta Tag                             350
           Creating Custom Children                             350
         Extending MXML Components                              351
         Summary                                                352

     Chapter 18: Extending Flex Components                      353
         A Look at Composite Components                         353
         Creating Composite Components                          354
            Properties                                          355
            Events                                              356
            Layout                                              357
         Extending Existing Components                          358
            Extending Button                                    358
            Extending TextInput                                 359
            Extending UIComponents versus Standard Components   360
            Appearance versus Behavior                          361
         Custom Containers                                      361
            Applying the Flex Component Life Cycle              362
            Tag Cloud                                           363
            Customizing Composite Components                    365
         Summary                                                367

     Chapter 19: Advanced Event Programming                     369
         Custom Events versus Standard Events                   369
           Extending Standard Events                            371
           One versus Many                                      371
         Adding Metadata to AS Class and MXML Files             372
           Adding Custom Events to Custom Components            372
           Handling Event Runtime Errors                        373

     xxvi



23642ftoc.indd 26                                                     5/2/09 4:16:22 PM
                                                                             Contents
                      Event Flow                                                   373
                        Event Priority                                             373
                        Preventing or Changing Default Behaviors                   374
                        Forwarding Events                                          374
                      Custom Data Binding                                          377
                        Using the Bindable Metadata Tag                            377
                        Custom Data Binding with the Bindable Metadata Tag         377
                      Using BindingUtils                                           380
                        Custom Data Binding in ActionScript                        380
                        ChangeWatcher                                              380
                      Summary                                                      381

                    Chapter 20: State Management                                  383
                      What Are States?                                             383
                        The States Property                                        384
                      Adding States                                                384
                        Creating States Using Flex Builder’s Design View           384
                        Changing States                                            387
                        Testing the Example                                        387
                      Understanding the MXML Tags                                  388
                        Adding Components                                          388
                        Removing Components                                        389
                        Gone, But Not Destroyed                                    389
                        Setting and Changing Properties and Styles                 390
                        Changing Event Handlers                                    390
                        Data Binding                                               391
                      Creating States in ActionScript                              391
                      Real Estate Management                                       393
                      Common Problems                                              393
                        States versus ViewStacks                                   394
                        Optimization                                               394
                      Anticipating Transitions                                     395
                      Summary                                                      396

                    Chapter 21: Using Libraries                                   397
                      ActionScript Libraries                                       397
                        Flash Player Library                                       398
                        Flex Libraries                                             398
                      SWCs versus SWFs                                             399
                        Anatomy of a SWC                                           399
                      Creating a Library with Flex Builder                         399
                        Creating a Library Project                                 399

                                                                                  xxvii



23642ftoc.indd 27                                                               5/2/09 4:16:22 PM
     Contents
           Adding Sources                         400
           Creating the SWC                       400
         Creating Libraries with COMPC            402
           COMPC Options                          403
           Adding Assets                          403
           Specifying the Manifest File           403
         Best Practices for Component Libraries   404
           Sharing Source Directories             404
           Build to Sell                          405
         Using Libraries                          405
           The libs Folder                        405
           The Build Path                         406
           Using Assets from Libraries            407
           Using SWC Files                        407
         Summary                                  408

     Part V: Visual Effects and Multimedia        409
     Chapter 22: Styles                           411
         What Are CSS Styles?                     411
           Inline Styling Versus CSS              411
           Component Styles                       413
           CSS Constraint-Based Layout            415
           CSS Styles and Class Inheritance       418
           CSS Styles and Subcomponents           419
         Summary                                  422

     Chapter 23: Skinning and Themes              423
         What Are Skins?                          423
           Embedded Assets                        423
           Programmatic Skins                     424
           Applying Skins                         424
           Defining Skins per Object              426
           Defining Skins in Style Sheets         426
           Scaling and Scale-9 Grids              428
           Changing Styles at Runtime             430
         Themes                                   433
           Default Flex 3 Themes                  433
           Applying Themes                        433
           Creating Themes                        435
           Separating Themes to Libraries         435
         Summary                                  435


     xxviii



23642ftoc.indd 28                                       5/2/09 4:16:22 PM
                                                                       Contents
                    Chapter 24: Visual Effects                              437
                      What Are Flex Effects?                                 437
                        Built-In Flex Effects                                440
                        Applying Effects                                     446
                        Data Effects                                         448
                        Easing Functions                                     449
                        Composite Effects                                    450
                        Transitions                                          454
                        Effect Events                                        457
                        3D Effects                                           458
                        Flex 4 Effects                                       458
                      Summary                                                459

                    Chapter 25: Dynamic Skinning and the Drawing API        461
                      Understanding the Drawing API                          461
                        Basic Programmatic Drawing                           462
                      Programmatic Skins                                     471
                        Creating and Applying Programmatic Skins             472
                      Additional Drawing API Capabilities                    475
                        Masks                                                476
                        Filters                                              477
                        Blend Modes                                          478
                        Degrafa                                              479
                      Summary                                                479

                    Chapter 26: Flash Integration                           481
                      Flash Platform Development Workflows                   482
                      The Flash-Flex Workflow                                483
                      Creating Flex Component Skins in Flash                 485
                         Using the Flex Skin Design Extension                486
                      Skinning a Custom Flex Component                       490
                         Planning Your Custom Flex Component                 490
                         Building the Flex Component                         492
                         Building the Flash Skin                             494
                         Skinning the Flex Component                         498
                      Summary                                                501

                    Chapter 27: Loading External Assets                     503
                      Loading Images                                         503
                      The SWFLoader Class                                    506
                      The Loader Class                                       507

                                                                             xxix



23642ftoc.indd 29                                                         5/2/09 4:16:22 PM
     Contents
         Runtime Shared Libraries                              511
         Summary                                               511

     Chapter 28: Video and Sound                               513
         Methods for Bringing in Media                         513
            Usable File Formats                                514
            Integrating the Media Content                      515
         Understanding Progressive Loading and Streaming       519
            The Sound Class                                    519
            The SoundLoaderContext Class                       520
            Playing and Controlling Sound                      521
            Accessing ID3 Information                          525
            The SoundMixer Class                               528
            The Microphone Class                               528
         Video                                                 528
            Video Classes and Components                       528
            The VideoDisplay Component                         536
            Cue Points                                         538
            The Camera Class                                   538
            Undocumented Video Classes                         539
            Flash Player MovieStar Update                      539
         Summary                                               543

     Chapter 29: Advanced Flash Integration                    545
         Bringing Flex Classes into Flash                      545
            Importing Custom Flex Classes through RSLs         546
            Importing Native Flex Classes                      547
         Bringing Flash into Flex                              547
            The Flex Component Kit for Flash CS3               547
            Porting Flash Native Components into Flex          551
            Custom States and Transitions in Flex Components   556
         Summary                                               567

     Part VI: Data Management                                  569
     Chapter 30: Working with Data                             571
         XML                                                   571
           Quick XML Primer                                    571
           XML and ActionScript: Before E4X                    573
           XML and ActionScript 3.0: Using E4X                 576




     xxx



23642ftoc.indd 30                                                    5/2/09 4:16:22 PM
                                                                               Contents
                      Collections API                                                582
                        IList                                                        582
                        ICollectionView                                              582
                        ListCollectionView                                           586
                      Associative Arrays/Dictionary                                  589
                        Using Strings as Keys                                        589
                        Using Objects as Keys                                        590
                      Repeaters                                                      592
                        During Execution                                             592
                        After Execution                                              593
                        Handling Interaction                                         593
                        When Not to Use Repeater                                     594
                      Summary                                                        594

                    Chapter 31: Formatters and Validators                           595
                      Overview                                                       595
                      Formatters                                                     596
                        Using Standard Formatters                                    596
                        Handling Input Data Errors                                   600
                      Validators                                                     601
                        Using Standard Validators                                    602
                        Changing the Default Error Messages                          605
                        Triggering Validation                                        606
                      Regular Expressions in ActionScript 3                          607
                        Common Regular Expression Use Cases                          607
                        A Regular Expression Primer                                  607
                      RegExpValidator: A Validator’s Validator                       608
                      Customizing and Centralizing Formatters and Validators         609
                        Centralizing Formatters                                      609
                        Centralizing Validators                                      610
                      Summary                                                        612

                    Chapter 32: Using the List Components                           613
                      ListBase Is Everywhere                                         613
                         ListBase APIs                                               614
                      Working with the List Class                                    617
                         Item-Editing Functionality in List                          618
                         List Descendents                                            619
                      The Menu Class                                                 619
                         Creating Menu Objects                                       619
                         Working with the Menu Class                                 620



                                                                                     xxxi



23642ftoc.indd 31                                                                 5/2/09 4:16:22 PM
     Contents
         The TileBase Class                                                  621
            HorizontalList                                                   621
            TileList                                                         621
         List, HorizontalList, and TileList — Optimized Memory Consumption   622
         Summary                                                             622

     Chapter 33: Advanced Data Controls                                      623
         Overview                                                            623
         Tree                                                                624
            Feeding the Tree                                                 624
            Changing the Look of the Tree                                    625
            Working with the Tree Control                                    626
         DataGrid                                                            628
            Populating the DataGrid                                          628
            Working with Columns                                             629
            Handling Events                                                  631
         Customizing Renderers                                               632
            Customizing Cells                                                632
            Headers                                                          636
         AdvancedDataGrid                                                    637
            Implementing the AdvancedDataGrid                                637
            Grouping Data in the AdvancedDataGrid                            638
            Hierarchical Data in the AdvancedDataGrid                        639
         OLAPDataGrid                                                        640
            An OLAP Primer                                                   640
            Working with the OLAPDataGrid                                    640
         Summary                                                             644

     Chapter 34: Drag and Drop in Flex                                       647
         Overview                                                            647
         Working with Drag and Drop-Enabled Components                       648
           Enabling a List for Drag and Drop                                 650
           Moving an Item                                                    650
           Preventing Duplicates                                             651
         Working with Drag and Drop Events                                   651
         Adding Drag and Drop Support to Nonenabled Components               652
           Setting Up Your Component as a Drag Initiator                     653
           Setting Up Your Component as a Drop Target                        654
         Additional Drag and Drop Tips                                       655
           Custom DragSource Formats                                         655




     xxxii



23642ftoc.indd 32                                                                  5/2/09 4:16:22 PM
                                                                         Contents
                        Custom Drag Proxy                                      655
                        Maintaining Type Information                           656
                      Summary                                                  656

                    Chapter 35: Drag and Drop in AIR                          657
                      Overview of AIR Drag and Drop                            657
                        The Clipboard                                          658
                        The NativeDragManager                                  660
                      Dragging Data from an AIR Application                    662
                      Dragging Files to an AIR Application                     666
                      Summary                                                  669

                    Chapter 36: Using the Charting Components                 671
                      Understanding Charting                                   671
                        Assigning Data to a Chart                              671
                        Chart Types                                            672
                        Chart Axes                                             680
                        Chart Series                                           681
                        Chart Data Tips                                        682
                        Chart Legends                                          683
                      Runtime Chart Interaction                                684
                        Handling User Interaction                              684
                        Programmatic Interaction                               684
                      Customizing a Chart’s Look and Feel                      685
                        Custom Renderers                                       685
                        Styling                                                686
                        Effects                                                686
                      Summary                                                  687

                    Chapter 37: Resource Bundles and Data Localization        689
                      Overview                                                 689
                      L10n Using Properties Files                              690
                        Understanding Properties Files                         690
                        Dealing with Character Encoding                        691
                        Setting Up Locales in Your Flex Project                692
                      Implementing i18n in Flex 3                              694
                        Utilizing Your Resources                               694
                      Loading Resources at Runtime                             698
                        Resource Modules                                       698




                                                                             xxxiii



23642ftoc.indd 33                                                           5/2/09 4:16:22 PM
     Contents
           Programmatically Generating ResourceBundle          699
           Pairing Resources with Modules                      699
         Globalizing AIR Applications                          699
         Summary                                               700

     Part VII: Client Communications                           701
     Chapter 38: Browser Communication in Flex                 703
         Understanding the Web Context                         703
         Using flashVars to Pass Data into Flex                704
         Linking to an External Page URL                       706
         Interacting with JavaScript                           706
            Invoking JavaScript from Flex                      707
            Invoking ActionScript from JavaScript              708
            Passing Data Between ActionScript and JavaScript   709
         Using the Flex-Ajax Bridge                            717
         Disabling Browser Integration                         718
         Summary                                               719

     Chapter 39: HTML Mashups with AIR                         721
         Why Embed HTML in an AIR Application?                 721
         YouTube Sample                                        722
         Displaying HTML in AIR                                722
            Loading Remote Content                             723
            Loading In-Memory Content                          724
            Loading Local File Content                         724
         Interacting with JavaScript                           726
            Calling Embedded JavaScript from ActionScript      726
            Calling ActionScript from JavaScript               728
            Controlling the HTML DOM from ActionScript         729
         Summary                                               730

     Chapter 40: Deep Linking                                  731
         Deep Linking on the Web                               731
         Deep Linking with Flex                                732
            Fragment Identifiers in URLs                       733
         Flex 3 Support for Deep Linking                       733
            Using the BrowserManager API                       734
            Under the Hood: How Flex Deep Linking Works        738
         Real-World Deep Linking: the Space Image Browser      739
            Example #2: Working with Navigational States       740
            Example #3: A More Sophisticated Image Browser     743

     xxxiv



23642ftoc.indd 34                                                    5/2/09 4:16:22 PM
                                                                     Contents
                      Search Engine Indexing and Optimization              747
                      Related Technologies and Tools                       748
                        SWFAddress                                         748
                        UrlKit                                             748
                        History Manager                                    749
                      Summary                                              749

                    Chapter 41: System Interactions in Flex               751
                      Detecting Client System Capabilities                 751
                      Going Full Screen                                    757
                      Enabling Right-Click Context Menus                   760
                         Adding and Removing Context Menu Options          760
                         Invoking Actions from Context Menus               763
                      Limitations of System Interactions                   765
                         Limitations of Full-Screen Mode                   765
                         Limitations of Custom Context Menus               766
                      Summary                                              766

                    Chapter 42: Native Desktop Support with AIR           767
                      Working with Windows                                 767
                         Creating a Native Window                          768
                         The Native Window Explorer                        773
                      Native Menus                                         774
                         Context Menus                                     774
                         Windows- and Application-Level Menus              780
                      Interacting with the System Tray/Dock                782
                         Sending Notifications                             784
                      Detecting User Presence                              784
                      Monitoring Network Connection                        785
                      AIR Capabilities and the Flash Runtime               786
                      Enabling Full-Screen Mode                            787
                      Summary                                              787

                    Chapter 43: LocalConnection and Shared Objects        789
                      Overview                                             789
                      The LocalConnection Class                            789
                        SWF-to-SWF Communication                           790
                        Crossing Domain Boundaries                         792
                        Working with Data                                  793
                        Working around the 40KB Limit                      793
                        Standard LocalConnection Errors                    794


                                                                          xxxv



23642ftoc.indd 35                                                       5/2/09 4:16:22 PM
     Contents
         Working with Local Shared Objects                           794
           Creating or Retrieving Local Shared Objects               795
           Storing Data in Local Shared Objects                      795
           Retrieving Data from Local Shared Objects                 795
           Explicitly Saving Local Shared Objects                    795
           Deleting Properties and Destroying Local Shared Objects   797
           Additional Information                                    797
           Serializing Custom Classes                                799
         Summary                                                     801

     Chapter 44: File Management with Flex                           803
         Overview                                                    803
           Prerequisites                                             803
         Using the FileReference Class                               804
           Handling FileReference Events                             804
           Uploading Files                                           805
           Downloading Files with FileReference                      808
           Canceling a File Upload or Download                       808
         Working with Multiple Files                                 808
         Server-Side Considerations                                  810
         Summary                                                     811

     Chapter 45: Local File Management with AIR                      813
         File Operations                                             813
            Referencing Directories                                  813
            Referencing Files                                        814
            Navigating Paths                                         814
         Synchronous versus Asynchronous API                         816
            Copying a File Synchronously                             817
            Copying a File Asynchronously                            817
         Other File and Directory Operations                         819
            Checking for Existence                                   819
            Deleting Files and Directories                           819
            Moving Files and Directories                             819
            Enumerating a Directory                                  820
            Creating Temporary Directories and Files                 820
         Working with Native File Dialogs                            821
            Native Directory Browser                                 821
            Native Browse for Open Dialog                            822
            Native Browse for Open Multiple Dialogs                  824
            Native File Save Dialog                                  825



     xxxvi



23642ftoc.indd 36                                                          5/2/09 4:16:23 PM
                                                                               Contents
                      Reading and Writing File Data                                  826
                         Saving Bitmap Data as a JPEG File                           827
                         Reading XML Data from a File                                828
                      Filesystem Controls                                            828
                      Encrypted Local Data                                           831
                         Writing Data                                                831
                         Reading Data                                                831
                         Deleting Data                                               832
                      Summary                                                        832

                    Part VIII: Server Integration                                  833
                    Chapter 46: Introduction to RPC Services                        835
                      Overview                                                       835
                      The mx.rpc Libraries                                           837
                         Differences between MXML and ActionScript Classes           838
                         Parameter Binding versus Explicit Parameter Passing         838
                      Working with the HTTPService Component                         839
                      Working with the WebService Component                          841
                         Using a WebService in MXML                                  841
                         Calling a WebService in ActionScript                        844
                      Debugging Remote Service Calls                                 845
                         Network Packet Sniffing                                     846
                         Debug Tracing in mx.rpc                                     846
                      Choosing a Protocol and Server Implementation                  850
                      Alternative Server Implementations for AMF                     850
                      Summary                                                        851

                    Chapter 47: Error Handling                                      853
                      Exception Handling with Synchronous Code                       853
                        Flash Debug Player versus Release Player                     853
                        Try/Catch/Finally                                            855
                        Exception Bubbling                                           856
                        Custom Error Types                                           858
                      Asynchronous Error Handling with Events                        860
                        Important Error Events                                       861
                        Asynchronous Events in the Debug Player                      862
                      Summary                                                        863




                                                                                  xxxvii



23642ftoc.indd 37                                                                 5/2/09 4:16:23 PM
     Contents
     Chapter 48: Flex and Flash Media Server                                        865
         Benefits of Streaming Video with the FMS                                   865
           Exercise 1: Playing Video On Demand                                      866
         Setting Up Applications and Understanding Instances                        867
         Developing for the Flash Media Server in Flex                              868
           Exercise 2: Using the Bandwidth Check System of the Flash Media Server   869
         Understanding the Netstream with FMS                                       872
         Buffer Control                                                             873
         Publishing Video                                                           874
           Exercise 3: Using the Flash Media Server for Live and Recorded Streams   875
         Data with the Stream                                                       877
           Exercise 4: Flash Media Server                                           878
         Summary                                                                    880

     Chapter 49: RESTful Web Services with Flex and the Zend Framework              881
         What Is a RESTful Web Service?                                             881
         The Routes Sample RESTful API                                              882
           Setting Up the Server and Development Environment                        883
           Client Software You Might Need                                           886
         How Zend Works                                                             886
         The Flex Sample Application                                                889
           Retrieving Data from a RESTful Service                                   889
           Creating and Updating Data with a RESTful Service                        894
           Deleting Data from a RESTful Service                                     896
         Summary                                                                    896

     Chapter 50: Integrating Flex and Java                                          899
         Introduction to the Routes Web Service                                     899
         Setting Up the Server and Development Environment                          900
            Server Software Requirements                                            900
            Client Software You Might Need                                          902
         The Grails Routes Web Service                                              902
            Grails Code Supporting the Web Service                                  903
         The Flex Sample Application                                                906
            The RouteService.as Service Class                                       906
            Using IResponder                                                        906
            Working with Custom Server-Side Errors                                  909
         Summary                                                                    913




     xxxviii



23642ftoc.indd 38                                                                         5/2/09 4:16:23 PM
                                                                                  Contents
                    Chapter 51: Web Services with .NET and Flex                        915
                      Introduction to the Routes Web Service                            915
                      Setting Up the Server and Development Environment                 916
                         Server Software Requirements                                   916
                         Client Software You Might Need                                 918
                      The .NET Routes Web Service                                       918
                         .NET Code Supporting the Web Service                           918
                      The Flex Sample Application                                       921
                         The Import Web Service (WSDL) Tool                             922
                         Accessing the Web Service                                      924
                         Working with Custom Server-Side Errors                         925
                      Summary                                                           927

                    Chapter 52: Offline Data Access with AIR                           929
                      Introduction to SQLite                                            929
                         SQLite versus XML                                              930
                      Synchronous versus Asynchronous                                   930
                      Creating a Database                                               931
                         Opening a Database Asynchronously                              931
                         Opening a Database Synchronously                               933
                         Working with Data Definition Language                          933
                      Working with Data                                                 935
                         Creating Data                                                  936
                         Retrieving Data                                                938
                         Updating Data                                                  939
                         Deleting Data                                                  940
                      Using Transactions to Import Data                                 941
                      Making Online Data Available for Offline Access                   943
                         Importing XML into a SQLite Database                           944
                         Improving the XML to SQLite Importer                           948
                      Using Third-Party SQLite Database Management Applications         949
                      Summary                                                           949

                    Part IX: Data Services                                            951
                    Chapter 53: Introduction to LCDS                                   953
                      Overview of LCDS                                                  953
                        LCDS Resources                                                  955
                      Understanding LCDS                                                955
                        Data Service Solutions                                          956



                                                                                      xxxix



23642ftoc.indd 39                                                                    5/2/09 4:16:23 PM
     Contents
             Client Architecture                             956
             Server Architecture                             958
             The Service Types                               959
             Communication Channels                          961
             Action Message Format (AMF)                     962
          Creating an LCDS Project in Flex Builder           963
             The New Flex Project Wizard                     963
             Configuring the Application Server              966
          Troubleshooting                                    968
             Logging                                         968
             Server-Side Debugging                           969
          Summary                                            969

     Chapter 54: LCDS and ColdFusion                         971
          ColdFusion 8 and Integrated LCDS                   971
            LCDS-Specific ColdFusion Installation Screens    971
            LCDS-Specific ColdFusion Administrator Screens   973
          Event Gateways                                     975
            DataServicesMessaging                            976
            DataManagement                                   976
          Data Management                                    976
          Summary                                            977

     Chapter 55: The Message Service                         979
          Message Service Overview                           979
          Message Service Technology Explained               979
            Publish and Subscribe                            979
            Producers and Consumers                          980
            Messages Travel through a Channel                980
            Pushing Messages from the Server                 980
          Using the Message Service                          981
            Configuring a Destination on the Server          981
            Creating Messages on the Client                  983
            Sending Messages                                 984
            Receiving Messages                               985
            Declaring Producers and Consumers in MXML        986
            Filtering Messages                               987
            Detecting Connectivity                           988
            Publishing from the Server                       988
          Message Service Applications                       990
            Example 1: Chat Rooms                            990



     xl



23642ftoc.indd 40                                                  5/2/09 4:16:23 PM
                                                                               Contents
                        Example 2: Stock Price Ticker                               993
                        Example 3: Generating a PDF                                 997
                      Summary                                                      1004

                    Chapter 56: The Data Management Service                       1005
                      Overview of the DMS                                          1005
                      Why Use the DMS?                                             1006
                        All about Domain Modeling                                  1006
                        Create, Read, Update, Delete                               1006
                        Sharing Data Among Users                                   1006
                        Paging Large Data Sets                                     1007
                        Occasional Connectivity                                    1008
                      Seeing Is Believing: The Six-Line Demo                       1008
                        Line 1: Declaring a Data Service                           1009
                        Line 2: Declaring a Collection for the Managed Data        1009
                        Line 3: Providing Managed Data to a Data Grid              1009
                        Line 4: Filling the Collection                             1009
                        Line 5: Committing Changes and Synchronizing Clients       1010
                        Line 6: Reverting Changes                                  1010
                        Behind the Scenes                                          1010
                      DMS Technology Explained                                     1010
                        Client and Server Components                               1010
                        Managed Data                                               1011
                        Managed Relationships                                      1011
                        Client Programming                                         1012
                        Server Integration                                         1014
                        Client and Server Collaboration                            1015
                      Example Application: DMS Fleet Tracker                       1015
                        Domain Modeling                                            1016
                        DMS Configuration                                          1019
                        Custom Assemblers                                          1022
                        Client Coding                                              1024
                        Further Considerations                                     1027
                      Summary                                                      1028

                    Chapter 57: Advanced Data Management Services                 1029
                      Overview of DMS                                              1029
                      Summary-to-Details Modeling                                  1030
                        Replace Lazy Relationship with Get Item                    1030
                      Overcoming Item-Pending Errors                               1031
                        Repeated Attacks                                           1032



                                                                                        xli



23642ftoc.indd 41                                                                 5/2/09 4:16:23 PM
     Contents
         Managing Shared and User-Specific Data                  1033
           A Simple Instant Messaging System                     1033
           Creating a New MessageDetails Item                    1034
           Creating and Delivering the User Messages             1034
           Streaming AMF to an NIO End Point                     1036
         Learning More                                           1036
         Summary                                                 1037

     Chapter 58: The Data Services Stress Testing Framework     1039
         Overview                                                1039
         Stress Testing a Data Management Service Application    1041
            Prerequisites                                        1041
            Writing the Test Application                         1041
            Configuring the Server                               1044
            Configuring and Starting the Browser Servers         1046
            Compiling the Test Administrator                     1047
            Running the Stress Test                              1047
         Further Topics                                          1049
            Parameterizing Test Applications                     1049
            Preconfiguring the Test Administrator                1049
            Creating Customized Test Reports                     1050
         Summary                                                 1051

     Chapter 59: Using BlazeDS                                  1053
         Overview                                                1053
         BlazeDS Features                                        1054
           Services and Client Components                        1054
           Channels of Communication                             1055
           Integration Points                                    1055
         Developing a BlazeDS Project                            1056
           Installing the BlazeDS Turnkey                        1056
           Creating a Combined Flex/Java Project                 1057
           Using a Remote Object                                 1060
           HTTP and Web Services                                 1067
         Summary                                                 1071

     Part X: Using Cairngorm                                    1073
     Chapter 60: MVC Frameworks                                 1075
         What Is MVC?                                            1075
         MVC Components                                          1076
           Understanding the Data Model                          1076

     xlii



23642ftoc.indd 42                                                       5/2/09 4:16:23 PM
                                                                          Contents
                        Understanding the View                                1077
                        Understanding the Controller                          1077
                        Putting the Pieces Together                           1078
                      Why MVC?                                                1078
                        Abstraction                                           1079
                        Component Reuse                                       1079
                        Distributed Development                               1079
                        Maintenance                                           1080
                        Is There a Definitive MVC?                            1080
                      An MVC Approach to Component Architecture               1081
                      Summary                                                 1081

                    Chapter 61: Introduction to Cairngorm                    1083
                      Overview                                                1083
                      The Steps of a Cairngorm Interaction                    1083
                        The User Gestures                                     1084
                        An Event Is Dispatched                                1085
                        A Command Executes                                    1086
                        A Business Function Is Delegated                      1087
                        A Service Is Located and Invoked                      1089
                        The Model Is Located and Updated                      1090
                        The View Reflects the Changes                         1092
                      Summary                                                 1094

                    Chapter 62: Applied Cairngorm                            1095
                      Getting Started                                         1095
                      The Main Players                                        1096
                        Model Locator                                         1096
                        Front Controller                                      1102
                        Cairngorm Events                                      1104
                        Cairngorm Commands                                    1108
                        Business Delegates                                    1110
                        Service Locator                                       1113
                        Value Objects                                         1115
                      Summary                                                 1118

                    Chapter 63: Advanced Cairngorm                           1119
                      The Presentation Model Pattern                          1119
                        Using Cairngorm with Presentation Models              1120
                        Sample Cairngorm Presentation Model Application       1121
                        Domain Models                                         1124
                        Taking Things Further                                 1125

                                                                                 xliii



23642ftoc.indd 43                                                            5/2/09 4:16:23 PM
     Contents
         Organizing Cairngorm Projects                             1125
           Small Cairngorm Projects                                1125
           Large Cairngorm Projects                                1126
         Cairngorm Anti-Patterns                                   1127
           The Fat Controller                                      1127
           Model Locator Landfill                                  1128
           Chains of Dependency                                    1129
         Customizing Cairngorm                                     1131
           Logging Cairngorm Events and Commands                   1131
           Timing Asynchronous Commands                            1132
           Injecting Dependencies into Commands                    1133
           Stubbing the Service Layer                              1135
           Decentralized Controllers                               1136
           Disposable Controller                                   1137
         Summary                                                   1138

     Part XI: Application Development Strategies                  1139
     Chapter 64: Best Practices                                   1141
         Coding Standards                                          1141
           Consistency                                             1141
           Clarity                                                 1142
           Cleanliness                                             1142
         Object-Oriented Principles                                1149
           Encapsulation                                           1149
           When to Use Public/Private/Protected/Final Functions    1150
           Inheritance                                             1151
           Code Behind                                             1158
         Summary                                                   1160

     Chapter 65: The Security Model                               1161
           Understanding the Security Sandbox                      1161
           What Is crossdomain.xml?                                1162
           Local Sandboxes                                         1167
         Summary                                                   1169

     Chapter 66: Modular Application Development                  1171
         Overview                                                  1171
         Why Modular Development?                                  1172
         Building Components                                       1173
         Runtime Shared Libraries                                  1173


     xliv



23642ftoc.indd 44                                                         5/2/09 4:16:23 PM
                                                                     Contents
                      Using the Module and ModuleLoader Classes          1173
                        Cross-Module Communication                       1177
                        Cross-Module Data Access                         1182
                      Summary                                            1187

                    Chapter 67: Application Performance Strategies      1189
                      Understanding Object Creation Policies             1189
                      Structuring Data for Performance                   1190
                         Lazy Loading Data                               1190
                         Impacts of Multiple Service Invocations         1191
                      Managing Event Listeners and Data Bindings         1192
                         Collection Events                               1192
                         Cleaning Up Unused Event Listeners              1194
                         Weak Referenced Event Listeners                 1194
                         Cleaning Up Event Listeners Manually            1194
                      Associative Arrays and Dictionaries                1195
                      Working with Graphics                              1198
                         Frame Rates                                     1198
                         Using Bitmap Caching                            1198
                         Managing External SWF Content                   1199
                         Object Caching and Recycling                    1199
                      Summary                                            1201

                    Chapter 68: Project Documenting with ASDoc          1203
                      What Is ASDoc?                                     1203
                      Using ASDoc                                        1204
                      ASDoc Comments and Formatting                      1205
                        ASDoc Tags                                       1206
                        Classes                                          1206
                        Functions                                        1207
                        Properties                                       1208
                        Getters and Setters                              1209
                        Metadata                                         1210
                        Formatting with HTML                             1211
                        Referencing Outside Elements                     1212
                        Excluding Classes from Generated Output          1213
                        Applying Custom Templates                        1213
                      Summary                                            1214




                                                                             xlv



23642ftoc.indd 45                                                       5/2/09 4:16:23 PM
     Contents
     Chapter 69: Desktop Deployment with AIR                          1215
         Code Signing and Certificates                                 1215
            Acquiring a Certificate                                    1216
            Creating and Signing an AIR Package in Flex Builder        1218
            Code Signing with a Developer Certificate                  1220
         Package and Signing AIR Applications with the Command Line    1222
         Distributing AIR Applications                                 1222
            Web Page Badge Installation                                1223
            Using the Web Badge SDK                                    1223
            Silent Installations                                       1226
         Updating AIR Applications                                     1227
         Summary                                                       1228

     Chapter 70: Dual Deployment for Flex and AIR                     1229
         Coding by Interface                                           1229
           Pros                                                        1231
           Cons                                                        1231
           Setting Up the Flex Builder Projects                        1232
           Referencing the MainAppEntryPoint Component                 1233
           Working with the IApplicationPersistence Interface          1235
           Working with the ApplicationPersistenceFactory              1235
         Using Conditional Compilation                                 1238
           Pros                                                        1238
           Cons                                                        1238
           Overview of the Conditional Compilation Approach            1238
           Looking at the ApplicationPersistence File                  1239
           Configuring the Flex Compiler                               1240
         Summary                                                       1241

     Part XII: Testing and Debugging                                  1243
     Chapter 71: Debugging Flex Applications                          1245
         Overview                                                      1245
         Flash Debug Player                                            1245
         The Flex Builder Debugging Perspective                        1246
            Placing Breakpoints                                        1246
            Launching an Application in Debug Mode                     1249
            Stepping through Code                                      1250
            Examining Application State                                1252
         The Command-Line Debugger                                     1255



     xlvi



23642ftoc.indd 46                                                             5/2/09 4:16:23 PM
                                                                                         Contents
                      Additional Debugging Techniques                                        1255
                        Debugging Java Server-Side Code                                      1255
                        Monitoring Internet Traffic                                          1257
                        Application-Specific Debugging                                       1259
                        Making the Most of Logging                                           1259
                        Debugging Bindings                                                   1260
                        Adobe Public Bug Database and Issue Reporting System                 1262
                      Summary                                                                1265

                    Chapter 72: Using the Flex Profiler                                     1267
                      Overview                                                               1267
                      Before You Get Started                                                 1268
                      Profiling Basics                                                       1268
                         Performance Profiling and Optimization Best Practices               1268
                         Memory Profiling Basics                                             1270
                         Performance Profiling Basics                                        1270
                         Sampling Profiler Basics                                            1270
                      Flex Builder 3 Profiling                                               1271
                         The Profiling Perspective                                           1271
                         Launching the Profiler                                              1272
                         Using the Memory Profiler                                           1276
                         Using the Performance Profiler                                      1284
                         Filtering in the Profiler                                           1287
                         Saving and Loading Profiling Data                                   1289
                         Other Useful Features                                               1290
                      The Profilers in Action                                                1292
                         Using the Memory Profiler to Detect Leaks                           1292
                         Using the Performance Profiler to Optimize an Algorithm             1296
                      Creating Your Own Profiler                                             1300
                      Summary                                                                1301

                    Chapter 73: Unit Testing and Test-Driven Development with FlexUnit      1303
                      Overview                                                               1303
                      Why Write Tests?                                                       1304
                        Preventing Bugs in the First Place                                   1304
                        Gaining the Confidence to Refactor                                   1304
                        Driving Improvements in Design                                       1304
                        Writing Testable Software                                            1304
                        Happy Developers and Effortless Documentation                        1305




                                                                                               xlvii



23642ftoc.indd 47                                                                           5/2/09 4:16:23 PM
     Contents
         Technology and Terminology                    1305
           The FlexUnit Library                        1305
           Unit Tests, Test Cases, and Test Suites     1306
           Running Tests                               1306
         Test-Driven Development by Example            1307
           Preparing for Unit Testing                  1307
           Creating a Test Case                        1308
           Assembling a Test Suite                     1308
           Failing the Test!                           1309
           Prepare, Invoke, Assert                     1310
           Happy and Unhappy Paths                     1313
           Setting Up and Tearing Down                 1315
           White Belt in Testing                       1317
         Further Topics                                1318
           Organizing Test Suites                      1318
           Removing Dependencies with Mock Objects     1318
           Continuous Integration with Ant and Maven   1322
           Eventful Test Cases                         1323
           Test Coverage                               1323
           Behavior-Driven Development                 1324
         Summary                                       1324

     Chapter 74: The Logging Framework                 1327
         Overview                                      1327
         Using the Logging Framework                   1328
           Creating a Logging Target                   1328
           Getting the Right Logger                    1328
           Logging at Different Levels                 1329
           Filtering Log Statements                    1330
           Log Only When Necessary                     1330
         Customizing the Logging Framework             1331
           Implementing a Remote Logging Target        1331
           Implementing the Java Remote Logger         1332
           Creating a Client that Logs Remotely        1334
         Further Topics                                1335
           Embedded Log Viewer                         1335
           Stopwatch Logging                           1337
           Logging to Firebug with ThunderBolt         1339
           Removing Logging from Production Code       1341
         Summary                                       1342




     xlviii



23642ftoc.indd 48                                             5/2/09 4:16:23 PM
                                                                   Contents
                    Chapter 75: The Automation Framework              1343
                      Overview                                         1343
                      The Technology Explained                         1344
                        Recording and Playback                         1344
                        The Automation Libraries                       1345
                        Runtime or Compile-Time Automation             1345
                        Component Identification                       1346
                      Automating a Simple Application                  1346
                        Installing an Automation Tool                  1347
                        Creating a Testable Application                1347
                        Compiling for Automation                       1348
                        Recording a Test Script                        1349
                        Replaying a Test Script                        1352
                      Further Topics                                   1353
                        Automating Custom Components                   1353
                        Creating a Custom Agent                        1353
                      Summary                                          1354

                    Appendix A: ActionScript Language Comparison      1355
                      Runtime Environment Concerns                     1355
                        Compilation                                    1355
                        Runtime Engines                                1355
                        Memory Management                              1356
                        Block-Level Scoping                            1356
                        The Notion of Global Variables                 1357
                        Using Console Output                           1357
                      Language Differences                             1357
                        Working with Data Types                        1357
                        Type Casting                                   1359
                        Declarations                                   1359
                        Statement Termination                          1360
                        Regular Expressions                            1360
                      OOP Differences                                  1360
                        Classes, Filenames, and Packages               1360
                        Polymorphism                                   1361
                        Inheritance                                    1362
                        Access Modifiers                               1362
                        Dynamic Classes                                1362
                      Summary                                          1363


                    Index                                             1365

                                                                          xlix



23642ftoc.indd 49                                                     5/2/09 4:16:24 PM

								
To top