You are previewing Adobe® AIR™ Bible.
O'Reilly logo
Adobe® AIR™ Bible

Book Description

Adobe Integrated Runtime (AIR) lets you use scripting languages you already know and frees you from the dull parts of development—so you can focus on creating exciting and cost-saving application user interfaces using Flash, Flex, and JavaScript. Find all the tips, techniques, and best practices you need to succeed in this comprehensive reference, including installing AIR across Windows, Mac, or Linux; learning AIR programming, development, and debugging essentials; and much more.

Table of Contents

  1. Copyright
  2. About the Authors
  3. Credits
  4. Acknowledgements
    1. Ben
    2. Ryan
    3. Jeff
  5. Introduction
    1. Introduction
    2. Who the Book Is For
    3. How the Book Is Organized
      1. Part I
      2. Part II
      3. Part III
      4. Part IV
      5. Part V
    4. How to Use This Book
  6. I. Introduction to AIR
    1. 1. Clearing the AIR
      1. 1.1. Why Use AIR?
      2. 1.2. Comparable Technologies
        1. 1.2.1. Flash and AJAX for the Web
        2. 1.2.2. Silverlight
        3. 1.2.3. Google Gears
        4. 1.2.4. Java and .NET
      3. 1.3. AIR Development Platforms at a Glance
      4. 1.4. Summary
    2. 2. Setting Up Your Development Environment
      1. 2.1. Adobe Integrated Runtime
        1. 2.1.1. System requirements for AIR
        2. 2.1.2. Installing AIR
          1. 2.1.2.1. Windows
          2. 2.1.2.2. Mac OS X
        3. 2.1.3. Uninstalling AIR
          1. 2.1.3.1. Windows
          2. 2.1.3.2. Mac OS X
      2. 2.2. Development Environments
        1. 2.2.1. Flex Builder 3
          1. 2.2.1.1. Download and install Flex Builder
          2. 2.2.1.2. Create an AIR project
        2. 2.2.2. Flash CS3
          1. 2.2.2.1. Install Flash CS3
          2. 2.2.2.2. Configure your Publish Settings
          3. 2.2.2.3. Testing your AIR application
        3. 2.2.3. Dreamweaver CS3
          1. 2.2.3.1. Install Dreamweaver
          2. 2.2.3.2. Create a site
          3. 2.2.3.3. Create an application file
          4. 2.2.3.4. Configure AIR application settings
      3. 2.3. Summary
    3. 3. Building Your First AIR Application
      1. 3.1. Using Flex Builder 3
      2. 3.2. Using Flash CS3
      3. 3.3. Using Dreamweaver CS3
      4. 3.4. Summary
  7. II. Programming for AIR Essentials
    1. 4. Crash Course in AIR Programming
      1. 4.1. A closer look at ActionScript
        1. 4.1.1. What's new in AS3
          1. 4.1.1.1. Runtime exceptions and type checking
          2. 4.1.1.2. Sealed classes
          3. 4.1.1.3. Method closures
          4. 4.1.1.4. ECMAScript for XML
          5. 4.1.1.5. Regular expressions
          6. 4.1.1.6. Namespaces
          7. 4.1.1.7. New primitive types
        2. 4.1.2. AS3 classes and interfaces
          1. 4.1.2.1. Packages
          2. 4.1.2.2. Classes
          3. 4.1.2.3. Interfaces
          4. 4.1.2.4. Access modifiers
          5. 4.1.2.5. Methods
          6. 4.1.2.6. Using inheritance
        3. 4.1.3. Events
          1. 4.1.3.1. Constructing an event object
          2. 4.1.3.2. Dispatching an event
        4. 4.1.4. Display list
          1. 4.1.4.1. DisplayObject
          2. 4.1.4.2. DisplayObjectContainer
      2. 4.2. An Introduction to Flash
        1. 4.2.1. The Timeline
        2. 4.2.2. Working with text
          1. 4.2.2.1. Using the TextField
          2. 4.2.2.2. Static and dynamic text
          3. 4.2.2.3. Input text
        3. 4.2.3. The Library
          1. 4.2.3.1. Converting a symbol on the stage
          2. 4.2.3.2. The New Symbol window
          3. 4.2.3.3. Adding a folder
          4. 4.2.3.4. Adding a font or video
          5. 4.2.3.5. Adding audio
        4. 4.2.4. Using ActionScript in Flash
          1. 4.2.4.1. Setting the document class
          2. 4.2.4.2. Class linkage
          3. 4.2.4.3. Timeline ActionScript
      3. 4.3. The Highlights of Flex
        1. 4.3.1. MXML
          1. 4.3.1.1. Basic syntax
        2. 4.3.2. Components
          1. 4.3.2.1. UIComponent
          2. 4.3.2.2. Layout components
          3. 4.3.2.3. Controls
        3. 4.3.3. Event handling
      4. 4.4. Summary
    2. 5. Development Essentials
      1. 5.1. The AIR Security Model
        1. 5.1.1. Sandboxes
          1. 5.1.1.1. About application sandboxes
          2. 5.1.1.2. The application sandbox
          3. 5.1.1.3. Nonapplication sandboxes
        2. 5.1.2. Code signing
          1. 5.1.2.1. Digital certificates
          2. 5.1.2.2. Obtaining a certificate
          3. 5.1.2.3. Signing your application
          4. 5.1.2.4. Signature timestamps
        3. 5.1.3. Best practices
          1. 5.1.3.1. The application sandbox
          2. 5.1.3.2. Sensitive information and credentials
          3. 5.1.3.3. Downgrade attacks
      2. 5.2. Basic Application Properties
        1. 5.2.1. Basic settings
          1. 5.2.1.1. id
          2. 5.2.1.2. Filename
          3. 5.2.1.3. Version
          4. 5.2.1.4. Description
          5. 5.2.1.5. Name
          6. 5.2.1.6. Copyright information
        2. 5.2.2. Installation settings
          1. 5.2.2.1. Install folder
          2. 5.2.2.2. Program menu folder
        3. 5.2.3. Window settings
          1. 5.2.3.1. Content and title
          2. 5.2.3.2. Appearance and transparency
          3. 5.2.3.3. Resizing
          4. 5.2.3.4. Window sizing and positioning
      3. 5.3. Summary
    3. 6. Debugging and Profiling
      1. 6.1. Debugging Basics
      2. 6.2. Logging
      3. 6.3. Profiling Techniques
        1. 6.3.1. Monitoring the frame rate
        2. 6.3.2. Monitoring the total memory
        3. 6.3.3. Timing the code execution
        4. 6.3.4. Monitoring memory with the Flex Builder profiler
      4. 6.4. Memory and Performance Tips
        1. 6.4.1. Bypassing the Flex framework
        2. 6.4.2. Using mouseEnabled and mouseChildren properties
        3. 6.4.3. Setting stage quality
        4. 6.4.4. Using smart math
        5. 6.4.5. Reusing objects
        6. 6.4.6. Use weakly referenced event listeners
      5. 6.5. Summary
  8. III. AIR API
    1. 7. Communicating with the Local Machine
      1. 7.1. Differences among Operating Systems
        1. 7.1.1. Native menu support
        2. 7.1.2. System icons
        3. 7.1.3. Special characters
      2. 7.2. The AIR Security Sandbox
        1. 7.2.1. Malicious scripts
          1. 7.2.1.1. Hacked code libraries
          2. 7.2.1.2. Malicious strings
        2. 7.2.2. Sandbox types
          1. 7.2.2.1. Application sandbox
          2. 7.2.2.2. Remote sandbox
          3. 7.2.2.3. Local with filesystem sandbox
          4. 7.2.2.4. Local trusted sandbox
          5. 7.2.2.5. Local with network sandbox
          6. 7.2.2.6. Using sandboxes
      3. 7.3. Working with the Operating System
        1. 7.3.1. Monitoring the network
          1. 7.3.1.1. Monitoring a specific URL
        2. 7.3.2. Monitoring user presence
      4. 7.4. Summary
    2. 8. Using the Filesystem
      1. 8.1. Filesystem Basics
        1. 8.1.1. File objects
        2. 8.1.2. FileMode
        3. 8.1.3. FileStream
        4. 8.1.4. Filesystem information
      2. 8.2. Using Folders
        1. 8.2.1. Creating a folder
        2. 8.2.2. Creating a temporary folder
        3. 8.2.3. Copying and moving folders
        4. 8.2.4. Deleting folders
      3. 8.3. Using Files
        1. 8.3.1. Copying a file
        2. 8.3.2. Moving a file
        3. 8.3.3. Deleting a file
        4. 8.3.4. Reading and writing files
        5. 8.3.5. FileStream objects
        6. 8.3.6. Working with XML
      4. 8.4. File Encryption
      5. 8.5. Simple Text Editor
        1. 8.5.1. Setting up the MXML application file
        2. 8.5.2. Creating the user interface
        3. 8.5.3. Creating TestFileStream.as and its API
        4. 8.5.4. TextFileStream's API
        5. 8.5.5. Building TextFileStream
        6. 8.5.6. Main API
        7. 8.5.7. Building out Main
          1. 8.5.7.1. Managing Simple Text Editor's application state
          2. 8.5.7.2. Managing Simple Text Editor's application state
      6. 8.6. Summary
    3. 9. Using the Clipboard
      1. 9.1. Choosing a Clipboard Format
      2. 9.2. Copying Data to the Clipboard
      3. 9.3. Pasting Data from the Clipboard
      4. 9.4. Copy and Paste Sample Application
        1. 9.4.1. Getting started
        2. 9.4.2. Setting up Cairngorm
          1. 9.4.2.1. Set up the application model
          2. 9.4.2.2. Set up the application control
        3. 9.4.3. Implementing the view
      5. 9.5. Summary
    4. 10. Dragging and Dropping
      1. 10.1. Drag and Drop Classes
        1. 10.1.1. NativeDragManager
        2. 10.1.2. NativeDragOptions
        3. 10.1.3. NativeDragEvent
        4. 10.1.4. NativeDragActions
        5. 10.1.5. Clipboard
        6. 10.1.6. ClipboardFormats
        7. 10.1.7. ClipboardTransferMode
      2. 10.2. Dragging Out
        1. 10.2.1. Preparing the data for drag-out
        2. 10.2.2. Creating a Clipboard object
      3. 10.3. Sample Application
        1. 10.3.1. The Tumblr API
        2. 10.3.2. The application structure
        3. 10.3.3. Sending Tumblr posts
          1. 10.3.3.1. AbstractPost
          2. 10.3.3.2. RegularPost
          3. 10.3.3.3. PhotoPost
        4. 10.3.4. Dragging files
          1. 10.3.4.1. RegularForm.mxml
          2. 10.3.4.2. PhotoForm.mxml
      4. 10.4. Summary
    5. 11. SQLite Databases
      1. 11.1. Introducing SQLite
        1. 11.1.1. The anatomy of a database
        2. 11.1.2. The ACID principle
      2. 11.2. Getting Started with SQL
        1. 11.2.1. Connecting to a database
        2. 11.2.2. Creating a simple table
        3. 11.2.3. Understanding data types
        4. 11.2.4. Adding data to your table
        5. 11.2.5. Reading data out of a database
      3. 11.3. Managing SQL Databases
        1. 11.3.1. Using SELECT statements
          1. 11.3.1.1. The FROM clause and the JOIN clause
          2. 11.3.1.2. The WHERE clause
          3. 11.3.1.3. The GROUP BY clause and the HAVING clause
          4. 11.3.1.4. Compound SELECT statements
          5. 11.3.1.5. The ORDER BY clause
          6. 11.3.1.6. The LIMIT clause
        2. 11.3.2. Maintaining your database
          1. 11.3.2.1. The UPDATE statement
          2. 11.3.2.2. The DELETE statement
          3. 11.3.2.3. The ALTER TABLE statement
      4. 11.4. Summary
    6. 12. Using Native Operating System Windows
      1. 12.1. Creating System Windows
        1. 12.1.1. Window types
          1. 12.1.1.1. NativeWindowType.NORMAL
          2. 12.1.1.2. NativeWindowType.UTILITY
          3. 12.1.1.3. NativeWindowType.LIGHTWEIGHT
        2. 12.1.2. Window chrome
          1. 12.1.2.1. NativeWindowSystemChrome.NONE
          2. 12.1.2.2. NativeWindowSystemChrome.STANDARD
        3. 12.1.3. Window sizing and positioning
      2. 12.2. Controlling System Windows
        1. 12.2.1. Minimizing, maximizing, and restoring windows
          1. 12.2.1.1. minimize();
          2. 12.2.1.2. maximize();
          3. 12.2.1.3. restore();
          4. 12.2.1.4. close();
        2. 12.2.2. Managing multiple windows
          1. 12.2.2.1. orderToFront();
          2. 12.2.2.2. orderToFrontOf();
          3. 12.2.2.3. orderToBack();
          4. 12.2.2.4. orderBehind();
        3. 12.2.3. Adding content to windows
          1. 12.2.3.1. Adding SWF content
          2. 12.2.3.2. Adding HTML Content
          3. 12.2.3.3. Adding dynamic content
        4. 12.2.4. NativeWindow Events
      3. 12.3. Using Application Icons
        1. 12.3.1. Taskbar and dock icons
          1. 12.3.1.1. Windows taskbar icons
          2. 12.3.1.2. OS X dock icons
        2. 12.3.2. Systray icons
        3. 12.3.3. Dynamic icons
      4. 12.4. Twitter Client Sample Application
        1. 12.4.1. Using the Twitter API
        2. 12.4.2. Creating Toast-styled windows
          1. 12.4.2.1. Toast windows
          2. 12.4.2.2. The Toaster
        3. 12.4.3. Creating the dialog boxes
          1. 12.4.3.1. The login window
          2. 12.4.3.2. The status update input window
        4. 12.4.4. Putting it all together
          1. 12.4.4.1. The Main application
      5. 12.5. Summary
    7. 13. HTML Content
      1. 13.1. Accessing the AIR API
      2. 13.2. Using the AIR HTML Introspector
      3. 13.3. Using Dreamweaver
      4. 13.4. Summary
  9. IV. Building an Application
    1. 14. Preparing to Build a Large-Scale Application
      1. 14.1. Planning an Application
        1. 14.1.1. Ideation
          1. 14.1.1.1. Who
          2. 14.1.1.2. What
          3. 14.1.1.3. Where
          4. 14.1.1.4. When
          5. 14.1.1.5. Why
          6. 14.1.1.6. How
        2. 14.1.2. Selecting a development path
        3. 14.1.3. Information architecture
      2. 14.2. The Architecture Phase
        1. 14.2.1. Architecture frameworks
          1. 14.2.1.1. Cairngorm
          2. 14.2.1.2. PureMVC
        2. 14.2.2. Leveraging existing libraries
      3. 14.3. Summary
    2. 15. Building a Reusable Config Class
      1. 15.1. Defining the XML
        1. 15.1.1. Defining capability requirements
        2. 15.1.2. Loading the XML
          1. 15.1.2.1. Using File and FileStream
          2. 15.1.2.2. Using URLLoader
      2. 15.2. Resolving Dynamic Properties
      3. 15.3. Using Composition for Event Dispatching
      4. 15.4. Global Accessibility
        1. 15.4.1. Choosing an approach
          1. 15.4.1.1. Delegation
          2. 15.4.1.2. The Singleton design pattern
        2. 15.4.2. Implementing the Singleton pattern
      5. 15.5. Your Config Class in Action
      6. 15.6. Summary
    3. 16. Application Design Best Practices
      1. 16.1. Preventing Spaghetti Code
        1. 16.1.1. How spaghetti has changed
        2. 16.1.2. Make ravioli instead
          1. 16.1.2.1. Encapsulation
          2. 16.1.2.2. Documentation
          3. 16.1.2.3. Entropy
      2. 16.2. Flex and Flash Guidelines
        1. 16.2.1. Transitions
        2. 16.2.2. Combining MXML with ActionScript
      3. 16.3. General Coding Guidelines
        1. 16.3.1. Package structuring
        2. 16.3.2. Using interfaces
      4. 16.4. Summary
    4. 17. SDK Development
      1. 17.1. SDK Development Essentials
        1. 17.1.1. Application descriptor file
        2. 17.1.2. Source files
      2. 17.2. Compiling Applications
        1. 17.2.1. The acompc compiler
        2. 17.2.2. The acompc configuration file
        3. 17.2.3. Component compiler usage examples
      3. 17.3. Debugging
        1. 17.3.1. ADL command-line arguments
        2. 17.3.2. ADL examples
      4. 17.4. Summary
    5. 18. Sample Application: LogReader
      1. 18.1. Requirements
        1. 18.1.1. Functionality
        2. 18.1.2. User interface
      2. 18.2. Architecture
        1. 18.2.1. Making the application updatable
        2. 18.2.2. Preparing the API
        3. 18.2.3. Creating the application view and logic
      3. 18.3. Testing
      4. 18.4. Summary
    6. 19. Polishing a Finished Application
      1. 19.1. The Importance of Design and Usability
        1. 19.1.1. The relationship between function, usability, and design
        2. 19.1.2. Properties of good design
          1. 19.1.2.1. Layout
          2. 19.1.2.2. Typography
          3. 19.1.2.3. Color palettes
          4. 19.1.2.4. Transitions
          5. 19.1.2.5. Sound
        3. 19.1.3. Properties of good experience
          1. 19.1.3.1. Keyboard shortcuts and versatility
          2. 19.1.3.2. Language support
          3. 19.1.3.3. Accessibility
          4. 19.1.3.4. Performance and reliability
      2. 19.2. Flex Builder 3 Design Tutorial
        1. 19.2.1. Cascading Style Sheets
        2. 19.2.2. Embedding assets
        3. 19.2.3. Creating custom components
        4. 19.2.4. Programmatic skins
        5. 19.2.5. Using Flex states to guide transitions
      3. 19.3. Summary
  10. V. Testing and Deploying
    1. 20. Deployment Workflow
      1. 20.1. Deploying from the Flex Builder 3 IDE
      2. 20.2. Deploying from the Flash CS3 IDE
      3. 20.3. Deploying from the Dreamweaver CS3 IDE
      4. 20.4. Compiling, Testing, and Deploying with Command-line Tools
        1. 20.4.1. Using MXMLC to compile an SWF file
        2. 20.4.2. Using ADL to test an application
        3. 20.4.3. Using ADT to generate a digital certificate
        4. 20.4.4. Using ADT to package an AIR file
      5. 20.5. Summary
    2. 21. Leveraging Ant to Automate the Build Process
      1. 21.1. Getting Set Up
        1. 21.1.1. Adding Ant view to the stand-alone Flex Builder IDE
        2. 21.1.2. Installing Ant on your machine
      2. 21.2. Creating a Build File
        1. 21.2.1. Defining properties
        2. 21.2.2. Defining targets
        3. 21.2.3. Defining tasks
        4. 21.2.4. Executing targets
      3. 21.3. Adding Basic Targets
        1. 21.3.1. Main target
        2. 21.3.2. Init target
        3. 21.3.3. Compile targets
        4. 21.3.4. Launch target
        5. 21.3.5. Generate certificate target
        6. 21.3.6. Deploy target
        7. 21.3.7. Clean target
      4. 21.4. Adding Advanced Targets
        1. 21.4.1. Generate documentation target
        2. 21.4.2. Export and package source target
        3. 21.4.3. User input target
      5. 21.5. Summary
    3. 22. Installation and Distribution
      1. 22.1. Implementing an Update System
        1. 22.1.1. Version tracking
        2. 22.1.2. Notifying the user that updates are available
        3. 22.1.3. Downloading and installing updates
      2. 22.2. Using the Adobe Install Badge
      3. 22.3. Creating a Custom Install Badge
      4. 22.4. Manual Installation
      5. 22.5. Summary