ActionScript Developer's Guide to PureMVC

Book description

Gain hands-on experience with PureMVC, the popular open source framework for developing maintainable applications with a Model-View-Controller architecture. In this concise guide, PureMVC creator Cliff Hall teaches the fundamentals of PureMVC development by walking you through the construction of a complete non-trivial Adobe AIR application.

Through clear explanations and numerous ActionScript code examples, you’ll learn best practices for using the framework’s classes in your day-to-day work. Discover how PureMVC enables you to focus on the purpose and scope of your application, while the framework takes care of the plumbing in a maintainable and portable way.

  • Get a detailed overview of the PureMVC process for developing your application
  • Model the domain by designing the schema and creating framework-agnostic value objects
  • Implement framework-agnostic View components that expose an API of events and properties
  • Use the Proxy pattern to keep track of value objects and hide service interaction
  • Facilitate two-way communication between a View component and the rest of the application
  • Stitch the Model and View tiers together with command objects in the Controller
  • Manage problematic View component life cycles, and learn how to reuse the Model tier

Publisher resources

View/Submit Errata

Table of contents

  1. Dedication
  2. A Note Regarding Supplemental Files
  3. Preface
    1. Code at the Speed of Thought
    2. The Purpose of This Book
    3. Who Should Read This Book
    4. Acknowledgements
      1. PureMVC Contributors
      2. Enneagram Personality System
    5. Conventions Used in This Book
    6. Using Code Examples
    7. Safari® Books Online
    8. How to Contact Us
  4. 1. Introduction
    1. Classic MVC Architecture
    2. The PureMVC AS3 Reference Implementation
    3. The Role of PureMVC in Your Application
      1. Pay No Attention to the Man Behind the Curtain
      2. Meet the Workhorses
    4. Actors at the Boundaries
      1. Use a Proxy as a Data Source for the Application
        1. A simple proxy example
        2. EmailConfigProxy
      2. Use a Mediator as a Secretary for a View Component
        1. A simple mediator example
        2. EmailConfigMediator
    5. Actors Between the Boundaries
      1. Let SimpleCommands Do Most of the Thinking
        1. PerformEmailTestCommand
      2. Use a MacroCommand to Execute Several SimpleCommands
    6. The Rest of the Gang
      1. Notifications
      2. The Core Actors
      3. The Facade
    7. Packaging Your Classes
      1. Ordinary Classes
      2. Framework Classes
      3. Typical Package Structure
    8. Standard and MultiCore Versions
    9. Writing Portable Code
  5. 2. Building an Application with PureMVC
    1. Choosing the Platform
    2. It Was a Dark and Stormy Night
    3. StoryArchitect, A Tool for Writing Fiction
      1. Statement of Purpose
      2. Determining Scope
      3. Describing the Domain
      4. Imagining the User Interface
      5. Persistence Strategy
    4. Erecting the Startup Scaffolding
      1. Prepare the Project and Initial Package Structure
      2. Create an Application Constants Class
        1. Class
        2. Code
      3. Create a Startup Command
        1. Class
        2. Code
      4. Create the Application Facade
        1. Class
        2. Code
      5. Initialize the Application Facade and call startup()
        1. Class
        2. Code
    5. Building from the Outside In
      1. Step 1: Value Objects
      2. Step 2: View Components
      3. Step 3: Proxys
      4. Step 4: Mediators
      5. Step 5: Commands
  6. 3. Modelling the Domain
    1. Designing the Schema
      1. Reviewing the Entities
      2. Creating the Schema
        1. ValueObject
        2. Note
        3. Setting
        4. Milieu
        5. Character
        6. Cast
        7. Draft
        8. Scene
        9. Chapter
        10. Part
        11. Story
        12. Season
        13. Series
    2. Creating the Value Objects
      1. A Simple Case
        1. NoteVO
      2. A Slightly More Complex Case
        1. ValueObject
      3. An Advanced Case
        1. StoryVO
    3. Creating the Enums
      1. Enumerating the Enums
      2. The Base Class
        1. Enum
      3. An Enum Subclass
        1. StoryTypeEnum
    4. Testing the Entities
      1. A Flex Unit Test Class
        1. NoteVOTest
  7. 4. Implementing the User Interface
    1. A Tale of Two Views
      1. The Application
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      2. The Chooser
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      3. The Story Chooser
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      4. The Editor
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      5. The Editor Controls
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      6. The Details Component
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      7. The Item Info Component
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      8. The Notes Component
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      9. The Timeline Component
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      10. The Story Tile
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      11. The Part Tile
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      12. The Chapter Tile
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      13. The Scene Tile
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      14. The Draft Tile
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      15. The Selection Context
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      16. The App Event
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
  8. 5. Proxying the Model
    1. Proxy Life Cycle
    2. Persistence Strategy Revisited
      1. What Proxys Do We Need?
      2. How will we store the data?
      3. Indexing
        1. A sample index.xml file
    3. Building the Proxys
      1. The Abstract Proxy
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      2. The Cast Proxy
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      3. The Milieu Proxy
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      4. The Story Proxy
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      5. The Series Proxy
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
  9. 6. Mediating the View
    1. Mediator Life Cycle
    2. Communicating with the Component
    3. Communicating with the Application
      1. Notification Interests
      2. Handling Notifications
      3. Collaboration with Proxys
      4. Avoid Retrieving Other Mediators
      5. Mediator Multiplicity
    4. Determining Granularity of Mediation
    5. Building the Mediators
      1. The Application Mediator
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      2. The Chooser Mediator
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      3. The Editor Mediator
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
  10. 7. Applying Business Logic
    1. Two Shades of Logic
      1. Domain Logic
      2. Business Logic
      3. Why the Distinction?
    2. Command Life Cycle
    3. Building the Commands
      1. The Startup Command
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      2. The Edit Story Command
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      3. The Apply Selection Command
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      4. The Remove Selection Command
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      5. The Apply Changes Command
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      6. The Discard Changes Command
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
      7. The Add Item Command
        1. Class
        2. Responsibilities
        3. Collaborations
        4. Code
    4. Registering the Commands
      1. Application Facade / initializeController()
        1. Class
        2. Method
        3. Responsibilities
        4. Code
  11. 8. Advanced Model Topics
    1. Handling Synchronous Behavior
      1. The Story Proxy
        1. Class
        2. Method
        3. Code
      2. The Apply Selection Command
        1. Class
        2. Methods
        3. Code
    2. Handling Asynchronous Behavior
      1. Separate Invoker and Responder(s)
      2. Single Invoker/Responder
      3. The Service Request
        1. Class
        2. Code
      4. The Search Story Command
        1. Class
        2. Code
      5. The Story Reading Proxy
        1. Class
        2. Code
    3. Reusing the Model Tier
      1. Step 1: Create a New Flex Library Project
      2. Step 2: Add Library Project to Flex Build Path in App Projects
      3. Extra Credit: Refactor the Startup Process
      4. The Application Facade
        1. Class
        2. Code
      5. The Startup Command
        1. Class
        2. Code
      6. The Prepare Controller Command
        1. Class
        2. Code
      7. The Prepare Model Command
        1. Class
        2. Code
      8. The Prepare View Command
        1. Class
        2. Code
      9. The Refactored Projects
  12. 9. Advanced View Topics
    1. Managing Pop Ups
      1. Past Approaches
      2. A Different Approach
      3. The Add, Change, and Delete Story Use Cases
      4. The Pop Up Request
        1. Class
        2. Code
      5. The Pop Up Action Event
        1. Class
        2. Code
      6. The Pop Up Interface
        1. Class
        2. Code
      7. The Confirmation Pop Up
        1. Class
        2. Code
      8. The Story Pop Up
        1. Class
        2. Code
      9. The Abstract Pop Up Mediator
        1. Class
        2. Code
      10. Story Pop Up Mediator
        1. Class
        2. Code
      11. The Confirmation Pop Up Mediator
        1. Class
        2. Code
      12. The Manage Story Command
        1. Class
        2. Code
    2. Deferred Instantiation
      1. The Application Sections TabNavigator
        1. Class
        2. Code
      2. The Application Sections Mediator
        1. Class
        2. Code
    3. Dynamically Adding View Components
      1. The Game Board
        1. Class
        2. Code
      2. The Game Board Mediator
        1. Class
        2. Code
    4. Flex Mobile Mediation Strategy
      1. Typical Flex or AIR Mediation
      2. Flex Mobile Mediation
      3. A Flex Mobile Example
        1. The IMyMobileApp Interface
        2. The MyMobileApp Application
        3. The Application Facade
        4. The Startup Command
        5. The Application Mediator
        6. The Mediate View Command
        7. The List View
  13. 10. Onward
    1. Using a Debugger with PureMVC
    2. PureMVC Utilities
    3. Other Resources
  14. About the Author
  15. Copyright

Product information

  • Title: ActionScript Developer's Guide to PureMVC
  • Author(s): Cliff Hall
  • Release date: December 2011
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449314569