Flash Development for Android Cookbook Over 90 recipes to build exciting Android applications with Flash, Flex, and AIR Joseph Labrecque [PACKTl III IV I V I J PUBLISHING BIRMINGHAM - MUMBAI
Preface 1 Chapter 1: Getting Ready to Work with Android: Development Environment and Project Setup Introduction 8 Using Flash Professional CS5.5 to develop Android applications 8 Targeting AIR for Android with Flash Professional CS5.5 10 Using Flash Builder 4.5 to develop Android applications 13 Enabling Flash Builder 4 or Flex Builder to access Flex Mobile SDKs 15 Using Flash Builder 4 and below to develop Android applications 18 Enabling Powerflasher FDT 4.1 to access Flex Mobile SDKs 21 Using Powerflasher FDT 4.1 and below to develop Android applications 23 Converting a standard Flex project to a Flex Mobile project 26 Configuring the AIR SDK to package AIR for Android applications on Windows 29 Configuring the AIR SDK to package AIR for Android applications on Linux or Mac OS 30 Chapter 2: Interaction Experience: Multitouch, Gestures, and Other Input33 Introduction Detecting supported device input types 34 Detecting whether or not a device supports multitouch 36 Verifying specific gesture support for common interactions 38 Using gestures to zoom a display object 41 Using gestures to pan a display object 43 Using gestures to swipe a display object 46 Using gestures to rotate a display object 49 Accessing raw touchpoint data 52 Creating a custom gesture based upon touchpoint data 55 Emulating the Android long-press interaction 59 7 34
Invoking the virtual keyboard programmatically 62 Responding to Android soft-key interactions 66 Responding to trackball and D-Pad events 68 Chapter 3: Movement through Space: Accelerometer and Geolocation Sensors Introduction 74 Detecting whether or not an Android device supports Detecting Android device movement in 3D space Z3 the accelerometer 74 Adjusting the accelerometer sensor update interval 78 Updating display object position through accelerometer events 82 Switching between portrait and landscape based upon device tilt 86 Detecting whether or not a device supports a geolocation sensor 89 Retrieving device geolocation sensor data 93 Adjusting the geolocation sensor update 76 interval 96 Retrieving map data through geolocation coordinates 101 Chapter 4: Visual and Audio Input: Camera and Microphone Access 107 introduction 107 Detecting camera and microphone support 108 Using the traditional camera API to save a captured image 110 Using the Mobile CameraUl API to save a captured photograph 113 Using the Mobile CameraUl API to save a captured video 118 Using the device microphone to monitor audio sample data 122 Recording Microphone Audio Sample Data 125 Chapter 5: Rich Media Presentation: Working with Images, Video, and Audio 131 Introduction 131 Loading photographs from the device cameraroll 132 Applying Pixel Bender Shader effects to loaded images 136 Playing video files from the local filesystem or over HTTP 141 Playing remote video streams over RTMP 146 Playing audio files from the local filesystem or over HTTP 152 Generating an audio spectrum visualizer 156 Generating audio tones for your application 159 Chapter 6: Structural Adaptation: Handling Device Layout and Scaling 163 Introduction 164 Detecting useable screen bounds and resolution 164 Detecting screen orientation changes 166 Scaling visual elements across devices at runtime 169 Scaling visual elements based on stage resize in Flash Professional CS5.5 172 -QD
Employing the Project panel in Flash Professional CS5.5 176 Freezing a Flex application to landscape or portrait mode 179 Defining a blank Flex mobile application 183 Defining a Flex mobile view-based application 185 Defining a Flex mobile tabbed application with multiple sections 188 Using a splash screen within a Flex mobile application 191 Configuring the ActionBar within a Flex mobile project for use with ViewNavigator 194 Hiding the ActionBar control in a single view for a Flex mobile project 198 Chapter 7: Native Interaction: StageWebView and URI Handlers 201 Introduction 201 Opening a website in the default Android browser 202 Rendering a website within an application 205 Managing the StageWebView history 210 Using StageWebView to load ads using ActionScript 216 Using StageWebView to load ads within a Flex mobile project 219 Making a phone call from an application 225 Sending a text message from an application 228 Invoking Google maps from an application 231 Invoking the Android Market using application URIs 236 Sending e-mail from an application 239 Chapter 8: Abundant Access; File System and Local Database 243 Introduction 243 Opening a local file from device storage 244 Saving a file to device storage 247 Saving data across sessions through local shared object 252 Storing application state automatically by using Flex 257 Creating a local SQLite database 260 Providing a default application database 266 Automating database tasks with FlexORM 271 Chapter 9: Manifest Assurance: Security and Android Permissions 279 Introduction 279 Setting application permissions with the Android Manifest file 280 Preventing the device screen from dimming 283 Establishing Android custom URI schemes 286 Anticipating Android Compatibility Filtering 290 Instructing an application to be installed to Device SDCard 292 Encrypting a local SQLite database 294 too-
Chapter 10: Avoiding Problems: Debugging and Resource Considerations 301 Introduction 301 Debugging an application with Flash Professional 302 Debugging an application with Flash Builder 305 Rendering application elements using the device GPU 310 Automating application shutdown upon device interruption events 311 Exiting your application with the device back button 313 Monitoring memory usage and frame rate in an application 314 Chapter 11: Final Considerations: Application Compilation and Distribution 319 Introduction 320 Generating a code-signing certificate using Flash Professional 320 Generating a code-signing certificate using Flash Builder 322 Generating a code-signing certificate using FDT 323 Generating a code-signing certificate using the AIR Developer Tool 325 Preparing icon files for distribution 327 Compiling an application using Flash Professional 330 Compiling an application using Compiling an application when using Flash Builder 334 FDT 336 Compiling an application using the AIR Developer Tool 337 Submitting an application to the Android Market 339 Index 343 HjD