Android™ Development with Flash®

Table of Contents

Chapter 1: Getting Started with Android Development

Introducing Android Devices

Introducing the Development Tools

Introducing the Available APIs

Check What APIs Are Not Available

Become an Android Developer

Get the Android SDK

Get the Android Eclipse Plug-in

Enable USB Debugging

Create an Android Virtual Device

Start the Emulator

Chapter 2: Getting Started with Flash CS5

Using the Actions Panel

Create a Skeleton Custom Class

Set the Source Path

Create MovieClips

Create Buttons

Edit Properties in Flash

Add Objects to the Stage with Code

Remove Objects from the Stage with Code

Work with Events

Using the Drawing API

Using Flash CS5 Help

Chapter 3: Developing Your First Application

Create a New Project

Configure Publish Settings

Set Your Application Output

Create a P12 Certificate

Compile from Flash Professional CS5

Compile from the Command Line

Install Your Application on Your Device

Update Your Version Number

Set Application Permissions

Set a Custom Application URI

Chapter 4: Designing Your Application

Mobile User Interface Guidelines

Understanding Screen Resolutions

Create Full-Screen Applications

Understanding Screen Orientation

Create Usable Hit States

Understanding Layout

Chapter 5: Handling Interaction

Create Button States

Respond to Touch Events

Track Multiple Touches

Respond to Zoom Events

Respond to Rotate Events

Respond to Pan Events

Respond to Swipe Events

Listen for Accelerometer Events

Determine If the Accelerometer Is Available

Determine Device Orientation

Detect Which Way Is Up

Filter Accelerometer Data

Chapter 6: Working with Images

Prepare Your Images

Import Images

Display Images

Bundle Images with Your Application

Load Images at Runtime

Create Images Dynamically

Save Images to the Camera Roll

Select Images from the Camera Roll

Display the Camera

Chapter 7: Working with Sound

Import Audio into Your Project

Choose an Audio Codec

Bundle Sounds with Your Application

Load Sounds at Runtime

Play Sounds

Stop Sounds

Set the Volume of a Sound

Visualize the Sound Spectrum

Access the Microphone

Chapter 8: Working with Video

Explore Available Video Formats and Encode a Video File

Convert Videos

Embed a Video

Bundle a Video with Your Application

Load a Video

Buffer a Video

Control a Video

Set the Volume of a Video

Chapter 9: Working with Text

Embed Fonts in Your Application

Create an Input TextField

Create a Password TextField

Using TLF TextFields

Create a Scrollable TextField

Chapter 10: Saving State

Create a Local SharedObject

Write to a SharedObject

Load Data from a SharedObject

Connect to a SQLite Database

Create a SQLite Table

Insert Data into a SQLite Table

Select Data from a SQLite Table

Update Data in a SQLite Table

Delete Data from a SQLite Table

Handle Application Exits

Save Application States

Handle Back and Menu Button Presses

Handle Application Deactivation

Chapter 11: Working with Files

Reference Files and Directories

Write Files

Read Files

Update Files

Append Files

Handle Files Synchronously

Copy Files

Load SWF files

Chapter 12: Using the Location and WiFi Features

Retrieve Your Current Location

Map Your Location with Yahoo!

Map Your Location with Google

Determine Your Speed

Check for an Internet Connection

Set the System Idle Mode

Display Web Pages

Chapter 13: Using Special URL Protocols

Make Phone Calls

Open the Mail Application

Open the Maps Application

Open the Messaging Application

Play a YouTube Video

Chapter 14: Integrating with Third-Party Services

Submit Updates to Twitter

Display Ads with Smaato

Track with Google Analytics

Display Ads with AdMob

Chapter 15: Optimizing Performance

Optimize Your Display List

Manage Mouse Events

Understanding cacheAsBitmap

Understanding cacheAsBitmapMatrix

Chapter 16: Debugging Your Application

Show Your Trace Statements

Create Breakpoints

Using the Flash CS5 Debugger

Understanding the Debug Console

Understanding the Variables Panel

Debug with the Android Eclipse Plug-in

Chapter 17: Deploying Your Application

Take Screenshots of Your Application on Your Device

Create an Application Icon

Publish Your Application for the Android Market

Upload Your Application to the Android Market

Appendix A: ActionScript Class Reference

Android™ Development
with Flash®

Your visual blueprint™ for
developing mobile apps


Trademark Acknowledgments

Contact Us


Acquisitions Editor

Aaron Black

Project Editor

Dana Rhodes Lesh

Technical Editor

Paul Geyer

Copy Editor

Dana Rhodes Lesh

Editorial Director

Robyn Siesky

Editorial Manager

Rosemarie Graham

Business Manager

Amy Knies

Senior Marketing Manager

Sandy Smith

Vice President and Executive Group Publisher

Richard Swadley

Vice President and Executive Publisher

Barry Pruett

Project Coordinator

Sheree Montgomery

Graphics and Production Specialists

Carrie A. Cesavice
Andrea Hornberger
Jennifer Mayberry

Quality Control Technicians

Rebecca Denoncour
Lindsay Littrell


Mildred Rosenzweig


Valerie Haynes Perry

Media Development Project Manager

Laura Moss

Media Development Assistant Project Manager

Jenny Swisher

Media Development Associate Producers

Josh Frank
Marilyn Hummel
Doug Kuhn
Shawn Patrick

Screen Artists

Ana Carillo
Cheryl Grubbs
Jill A. Proll
Ronald Terry

Cover Art Illustrator

Cheryl Grubbs

About the Author

Julian Dolce is the senior Flash developer at QNX Software Systems, specializing in mobile AIR applications. Julian has spoken at numerous conferences around the world, where he has taught workshops on moving from Flash development to iPhone development, as well as a number of AIR for Android development workshops. He also maintains a personal development blog,, in which he writes about his life as a Flash developer.

Author’s Acknowledgments

This book would not have been possible without the support of my close friends, Thomas, Elissa, Miles, Marco, Lori, Neil, and Sherisse. You guys put up with me for six months and made sure that I did not go insane. You are the best friends anyone could ask for.

Erin, your love, support and encouragement throughout my entire career has been a source of strength and inspiration. Your courage and determination has taught me that any dream, no matter how big, is never out of reach. You never stopped believing in me, and I cannot thank you enough for it.

Finally, to my parents and the rest of my family. You have supported me throughout my entire life, and I could not have gotten to where I am today without you.

How to Use This Visual Blueprint Book

Who This Book Is For

This book is for intermediate-to-advanced Flash developers who want to use their knowledge of Flash and ActionScript to develop AIR Android applications. This book specifically focuses on the Android platform, but many of the topics and examples can be used to develop for any AIR mobile platform.

The Conventions in This Book


001 Steps

This book uses a step-by-step format to guide you easily through each task. Numbered steps are actions you must do; bulleted steps clarify a point, step, or optional feature; and indented steps give you the result.

002 Notes

Notes give additional information — special conditions that may occur during an operation, a situation that you want to avoid, or a cross-reference to a related area of the book.

003 Extra or Apply It

An Extra section provides additional information about the preceding task — insider information and tips for ease and efficiency. An Apply It section takes the code from the preceding task one step further and allows you to take full advantage of it.

004 Bold

Bold type shows text or numbers you must type.

005 Courier Font

Courier font indicates the use of scripting language code such as statements, operators, or functions, and code such as objects, methods, or properties.


Italic type introduces and defines a new term.

Web Site

You can find the code samples throughout the book on the Wiley Web site, Search the site for this book’s page; then you can find the code samples on the Downloads tab.