Programming Flex 3

Book description

If you want to try your hand at developing rich Internet applications with Adobe's Flex 3, and already have experience with frameworks such as .NET or Java, this is the ideal book to get you started. Programming Flex 3 gives you a solid understanding of Flex 3's core concepts, and valuable insight into how, why, and when to use specific Flex features. Numerous examples and sample code demonstrate ways to build complete, functional applications for the Web, using the free Flex SDK, and RIAs for the desktop, using Adobe AIR. This book is an excellent companion to Adobe's Flex 3 reference documentation. With this book, you will:

  • Learn the underlying details of the Flex framework

  • Program with MXML and ActionScript

  • Arrange the layout and deal with UI components

  • Work with media

  • Manage state for applications and components

  • Use transitions and effects

  • Debug your Flex applications

  • Create custom components

  • Embed Flex applications in web browsers

  • Build AIR applications for the desktop

Flex 3 will put you at the forefront of the RIA revolution on both the Web and the desktop. Programming Flex 3 will help you get the most from this amazing and sophisticated technology.

Table of contents

  1. Programming Flex 3
    1. A Note Regarding Supplemental Files
    2. Foreword
    3. Preface
      1. Who This Book Is For
      2. How This Book Is Organized
      3. What You Need to Use This Book
      4. Conventions Used in This Book
      5. Using Code Examples
      6. Safari® Books Online
      7. Comments and Questions
      8. Acknowledgments
        1. From Chafic
        2. From Joey
    4. 1. Introducing Flex
      1. Understanding Flex Application Technologies
        1. Flash Player
        2. The Flex Framework
        3. Flex Builder 3
        4. Integrating with Data Services
        5. Integrating with Media Servers
        6. Additional Flex Libraries and Components
      2. Using Flex Elements
        1. MXML
        2. ActionScript
      3. Working with Data Services (Loading Data at Runtime)
      4. The Differences Between Traditional and Flex Web Applications
      5. Understanding How Flex Applications Work
      6. Understanding Flex and Flash Authoring
      7. What’s New in Flex 3
      8. Summary
    5. 2. Building Applications with the Flex Framework
      1. Using Flex Tool Sets
      2. Creating Projects
        1. Setting Up a New Project
          1. Creating an SDK project
          2. Creating a Flex Builder 3 project
      3. Building Applications
        1. Compiling Using mxmlc
          1. Configuring for Windows
          2. Configuring for OS X and Linux
          3. Beginning with the command line
          4. Specifying an output location
          5. Specifying source paths
          6. Customizing the application background color
          7. Changing script execution settings
          8. Setting metadata
          9. Using incremental builds
          10. Storing compiler settings in configuration files
        2. Using Ant
        3. Compiling Using Flex Builder
        4. Publishing Source Code
      4. Deploying Applications
      5. Summary
    6. 3. MXML
      1. Understanding MXML Syntax and Structure
        1. Creating MXML Documents
          1. XML encoding
          2. Applications, modules, and components
          3. Understanding namespaces
        2. Components
          1. Containers
          2. UI controls
          3. Setting component properties
          4. Non-visual components
      2. Making MXML Interactive
        1. Handling Events
        2. Using Data Binding
      3. Summary
    7. 4. ActionScript
      1. Using ActionScript
        1. Inline ActionScript
        2. Nested ActionScript
        3. MXML Scripts
        4. Classes
      2. MXML and ActionScript Correlations
      3. Understanding ActionScript Syntax
        1. Understanding Packages
        2. Declaring Classes
          1. Creating class files
          2. Package declarations
          3. Import statements
          4. Class declaration
      4. Variables and Properties
        1. Methods
        2. Expressions
        3. Statements
        4. Arrays
        5. Objects
      5. Inheritance
      6. Interfaces
      7. Handling Events
      8. Error Handling
        1. Handling Synchronous Errors
        2. Handling Asynchronous Errors
      9. Using XML
        1. Creating XML Objects
        2. Reading XML Data
        3. Writing to and Editing XML Objects
      10. Reflection
        1. Getting the Class Name
        2. Getting the Class by Name
        3. Class Introspection
      11. Summary
    8. 5. Framework Fundamentals
      1. Understanding How Flex Applications Are Structured
        1. SystemManager Instance
        2. Preloader Instance
        3. Application Instance
      2. Loading and Initializing Flex Applications
      3. Understanding the Component Life Cycles
      4. Loading One Flex Application into Another Flex Application
      5. Differentiating Between Flash Player and the Flex Framework
      6. Caching the Framework
      7. Understanding Application Domains
      8. Localization
        1. Resource Bundles
        2. Using ResourceManager
        3. Compile-Time Localization
        4. Runtime Localization
          1. Compiling multiple resource bundles into an .swf
          2. Loading resource modules at runtime
      9. Summary
    9. 6. Managing Layout
      1. Flex Layout Overview
        1. Working with Children
        2. Container Types
        3. Layout Rules
          1. Box-based layout
          2. Canvas-based absolute layout
          3. Canvas-based constraint layout
          4. Hybrid layout containers
          5. Additional layout rules
            1. The tile layout rule
            2. The grid layout rule
            3. The form layout rule
        4. Padding, Borders, and Gaps
        5. Nesting Containers
        6. Handling Scrolling and Clipping
        7. The Spacer Component
      2. Making Fluid Interfaces
      3. Putting It All Together
      4. Summary
    10. 7. Working with UI Components
      1. Understanding UI Components
        1. Creating Component Instances
        2. Common UI Component Properties
        3. Handling Events
          1. Handling events with MXML
          2. Handling events with ActionScript
          3. Event objects
          4. Standard Flex component events
      2. Buttons
      3. Value Selectors
      4. Text Components
      5. List-Based Controls
        1. Data Models
        2. Creating a Collection Object
        3. Setting the Data Provider
        4. Using Data Grids
          1. Using data providers
          2. Working with data grid columns
        5. The Advanced Data Control
          1. Creating an advanced data grid
          2. Selecting rows and columns
          3. Working with grouping data
          4. Grouping columns
          5. Working with hierarchical data
        6. Using Tree Controls
        7. Working with Selected Values and Items
      6. Pop-Up Controls
        1. Using PopUpButton
        2. Using PopUpMenuButton
        3. Listening to Menu Events
      7. Navigators
        1. Accordion Controls
        2. Option Bars
        3. View Stacks
      8. Control Bars
      9. Summary
    11. 8. Customizing Application Appearance
      1. Using Styles
        1. Style Value Formats
        2. Instance Styles
        3. Using CSS
        4. Style Properties
        5. Using StyleManager
        6. Global Styles
        7. Reviewing Style Precedence
        8. Working with Fonts
          1. System fonts
          2. Device fonts
          3. Embedded fonts
          4. Embedding font subsets
          5. Using advanced anti-aliasing
      2. Skinning Components
        1. Applying Skins
        2. Graphical Skinning
          1. Inline graphical skins
          2. Setting graphical skins with setStyle
          3. Using CSS to set graphical skins
          4. Using Scale-9
          5. Using Flash Library symbols
        3. Programmatic Skinning
        4. Skinning Application Backgrounds
        5. Skinning Tool Tips
      3. Customizing the Preloader
      4. Themes
        1. Setting a Theme
        2. Creating a Theme
      5. Runtime CSS
      6. Summary
    12. 9. Application Components
      1. The Importance of Application Components
      2. MXML Component Basics
        1. Creating and Using a Component
        2. Adding and Laying Out Controls
        3. Understanding Interaction
          1. Defining component properties
          2. Defining component methods
          3. Defining component events
      3. Component Styles
        1. Internal States
      4. Summary
    13. 10. Framework Utilities and Advanced Component Concepts
      1. Tool Tips
        1. Adding Tool Tips
        2. Adding Tool Tips Programmatically
        3. Controlling Tool Tip Width and Line Formatting
        4. Applying Styles to Tool Tips
        5. Customizing Tool Tip Settings
        6. Applying Effects
      2. Pop Ups
        1. Using Alerts
        2. Creating a Pop-Up Window
        3. Removing a Pop-Up Window
        4. Custom Pop-Up Component Types
        5. Adding Modality
      3. Cursor Management
      4. Drag-and-Drop
        1. Using Built-In Drag-and-Drop Features
        2. Understanding Drag-and-Drop Events
        3. Custom Drag-and-Drop Operations
      5. Customizing List-Based Controls
        1. Drop-In Item Renderers
        2. Inline Item Renderers
        3. Custom Components As Item Renderers
        4. Creating Item Editors
      6. Focus Management and Keyboard Control
        1. Controlling Tab Order
        2. Programmatically Controlling Focus
        3. Responding to Keyboard Events
      7. Summary
    14. 11. Working with Media
      1. Overview
        1. Supported Media Types in Flex
      2. Adding Media
        1. Loading Media
        2. Embedding Media
          1. Embedding media within MXML
          2. Embedding media within ActionScript
          3. Embedding media within CSS
      3. Working with the Different Media Types
        1. Working with Graphics
          1. Adding graphics
        2. Scaling Graphics Using a Scaling Grid (Scale-9)
          1. Working with SWF libraries
          2. Building an asset library using a static class in Flex
          3. Working with SWF animations
        3. Working with Audio and Video
          1. Adding a sound effect
          2. Advanced sound control
          3. Working with video
          4. Streaming media
      4. Summary
    15. 12. Managing State
      1. Creating States
      2. Applying States
      3. Defining States Based on Existing States
      4. Adding and Removing Components
      5. Setting Properties
      6. Setting Styles
      7. Setting Event Handlers
      8. Using ActionScript to Define States
        1. Defining States
        2. Adding States
        3. Adding Overrides
        4. Adding and Removing Child Elements
        5. Setting Properties and Styles
        6. Setting Event Handlers
        7. Using Dynamic States
      9. Managing Object Creation Policies (Preloading Objects)
      10. Handling State Events
      11. Understanding State Life Cycles
      12. When to Use States
      13. Summary
    16. 13. Using Effects and Transitions
      1. Using Effects
        1. Working with Effects
        2. Playing Effects
          1. Manually playing effects
          2. Using triggers
        3. Effect Events
        4. Composite Effects
        5. Pausing, Resuming, and Reversing Effects
        6. Delaying and Repeating Effects
        7. Customizing Animation Easing
        8. Using Effects and Fonts
        9. Using Effects with Lists
      2. Creating Custom Effects
        1. Defining an Effect Instance Class
        2. Defining an Effect Factory Class
        3. Using Custom Effects
        4. Creating Tween Effects
      3. Using Transitions
        1. Creating Transitions with MXML
        2. Creating Transitions with ActionScript
        3. Using Transition Filters
      4. Creating Custom Transitions
      5. Summary
    17. 14. Working with Data
      1. Using Data Models
        1. Using the Model Tag
          1. Creating tag-based model structures
          2. Populating a model from a file
          3. Referencing model data
        2. Using XML
          1. Specifying an XML structure with tags
          2. Loading XML from a file
          3. Referencing XML data
        3. Using ActionScript Classes
        4. Working with Collections
      2. Data Binding
        1. Understanding Data Binding Syntax
          1. Curly braces
          2. <mx:Binding>
          3. BindingUtils
      3. Enabling Data Binding for Custom Classes
        1. Customizing Data Binding
      4. Data Binding Examples
        1. Controlling Images
        2. Working with Web Services
      5. Building Data Binding Proxies
        1. Using Data Binding with a Shared Object
      6. Summary
    18. 15. Validating and Formatting Data
      1. Validating User Input
        1. Using Validators
          1. Validator basics
          2. Customizing validator messages
          3. Handling validator events
          4. Triggering validators
        2. Using Standard Framework Validators
          1. StringValidator
          2. NumberValidator
          3. DateValidator
          4. EmailValidator
          5. PhoneNumberValidator
          6. ZipCodeValidator
          7. CreditCardValidator
          8. CurrencyValidator
          9. SocialSecurityValidator
          10. RegExpValidator
        3. Writing Custom Validators
      2. Formatting Data
        1. NumberFormatter
        2. DateFormatter
        3. CurrencyFormatter
        4. PhoneFormatter
        5. ZipCodeFormatter
        6. Writing Custom Formatters
      3. Summary
    19. 16. Client Data Communication
      1. Local Connections
        1. Basic Local Connection Communication
        2. Legacy Communication
        3. Cross-Domain Communication
      2. Persistent Data
        1. Creating Shared Objects
        2. Reading and Writing to Shared Objects
        3. Controlling Scope
        4. Using Local Shared Objects
        5. Customizing Serialization
      3. Communicating with the Host Application
        1. Working with ExternalInterface
        2. Setting the Web Browser Status
        3. Integrating HTML and Flex Forms
      4. Summary
    20. 17. Remote Data Communication
      1. Understanding Strategies for Data Communication
      2. Working with Request/Response Data Communication
        1. Simple HTTP Services
        2. HTTPService
          1. Sending requests
          2. Handling responses
          3. Sending parameters
          4. Using HTTPService with ActionScript
        3. URLLoader
          1. Sending requests
          2. Handling responses
          3. Sending parameters
          4. Using URLLoader in a remote proxy
      3. Web Services
        1. Using WebService Components with MXML
          1. Calling web service methods
          2. Handling responses
          3. Sending parameters
        2. Using WebService Components with ActionScript
          1. Sending requests
          2. Sending parameters
          3. Handling responses
          4. Using WebService with a remote proxy
        3. Data Type Conversion
        4. Remoting
          1. Creating Remoting connections
          2. Calling Remoting methods
          3. Passing parameters to Remoting methods
          4. Using Remoting remote proxies
      4. Real-Time/Socket Connection
      5. File Upload/Download
        1. Downloading Files
        2. Uploading Files
      6. Summary
    21. 18. Application Debugging
      1. The Flash Debug Player
        1. Runtime Errors
        2. The Debugging API
        3. Using Show Redraw Regions
      2. Using FDB
      3. Debugging with Flex Builder
      4. Remote Debugging
        1. Establishing a Remote Debugging Session with the Flex Builder Debugger
      5. Logging Using trace() Within an Application
      6. The Logging Framework
        1. Specifying the Logging Options
        2. Defining a Custom Target
      7. Debugging Remote Data
        1. Debugging with the Flex Logging Framework
        2. Debugging Using a Data Inspector
      8. Summary
    22. 19. Building Custom Components
      1. Component Framework Overview
      2. Component Life Cycle
        1. Construction
        2. Configuration
        3. Attachment
        4. Initialization
        5. Invalidation
        6. Validation
        7. Destruction
      3. Component Implementation
        1. Implementing the Constructor
        2. Implementing createChildren()
        3. Understanding Invalidation
        4. Implementing commitProperties()
        5. Implementing measure()
        6. Implementing updateDisplayList()
      4. Adding Custom Properties and Events
      5. Adding Styling Support
      6. Summary
    23. 20. Embedding Flex Applications in a Web Browser
      1. Embedding a Flex Application in HTML
        1. Using HTML Tags to Embed Flex Content
        2. Passing Values to Flex Applications from HTML
        3. Detecting Flash Player
        4. Using the Standard Templates
        5. Using SWFObject
        6. Managing New Flex Application Builds
      2. Integrating with Browser Buttons and Deep Linking
        1. Working with BrowserManager
          1. Initializing BrowserManager
          2. Setting and retrieving a URL fragment
          3. Setting the page title
          4. Handling BrowserManager events
        2. Building a Sample BrowserManager Application
        3. Enabling BrowserManager to Manage Granular States
        4. Deploying BrowserManager Flex Applications
      3. Flash Player Security
      4. Using Runtime Shared Libraries
        1. Creating Runtime Shared Libraries with the Command-Line Compilers
          1. Using compc
          2. Compiling an application using a runtime shared library
          3. Using Ant to build runtime shared library applications
        2. Using Flex Builder to Build Runtime Shared Libraries
          1. Creating a Flex Library Project
          2. Linking an application to a library
        3. Adding Nonclass Assets to Runtime Shared Libraries
      5. Summary
    24. 21. Building AIR Applications
      1. Understanding AIR
      2. Building AIR Applications
        1. Creating a New Flex AIR Project
        2. Defining Descriptor Files
        3. Compiling and Testing AIR Applications
      3. Working with AIR Features
        1. Accessing the Local Filesystem
          1. Referencing files and directories
          2. Retrieving a directory listing
          3. Creating directories
          4. Reading and writing files
        2. Using Local SQL Databases
          1. Creating a database connection
          2. Running SQL statements
          3. Using parameters to insert data
          4. Retrieving results
        3. Managing Windows
          1. Creating a window
          2. Opening and closing windows
          3. Managing opened windows
        4. Working with Clipboards
          1. Copy and paste
          2. Drag and drop
        5. Using HTML
      4. Distributing AIR Applications
        1. Creating Installers
          1. Creating a self-signed certificate
          2. Creating an .air file using Flex Builder
          3. Creating an .air file using the SDK
        2. Creating a Badge
      5. Summary
    25. 22. Building a Flex Application
      1. Introducing the Sample Application
        1. Creating a Flickr Account
        2. Retrieving the Source Code
        3. Setting Up a New Project
        4. Configuring FlickrFlex
        5. Compiling the Application
        6. Running the Application
      2. Utilizing Best Practices
        1. Organizing Files
        2. Using CSS
        3. Application Components
        4. Versioning
        5. Unit Testing
      3. Using Blueprints and Microarchitectures
      4. Abstracting Common Patterns
        1. Understanding Browser Integration
        2. The Business Delegate Pattern
        3. The Model-View-Controller Pattern
          1. Models
          2. Controllers and views
      5. Summary
    26. Index
    27. About the Authors
    28. Colophon

Product information

  • Title: Programming Flex 3
  • Author(s):
  • Release date: September 2008
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596516215