Pro Android Flash Copyright © 2011 by Stephen Chin, Dean Iverson, Oswald Campesato, and Paul Trani All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-3231-5 ISBN-13 (electronic): 978-1-4302-3232-2 Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. President and Publisher: Paul Manning Lead Editor: Steve Anglin Development Editor: Tom Welsh Technical Reviewer: James Bucanek Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, James Markham, Matthew Moodie, Jeff Olson, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Jennifer L. Blackwell Copy Editor: Mary Ann Fugate Compositor: MacPS, LLC Indexers: BIM Indexing & Proofreading Services Artist: April Milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1- 800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer- sbm.com, or visit www.springeronline.com. For information on translations, please e-mail http://[email protected], or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at www.apress.com. To my loving wife and daughter, who supported me in completing this book, with full knowledge that they would be without a father for several months. Stephen Chin To my mother, who always made sure our house was full of books. Dean Iverson To my parents. Oswald Campesato To my father, who loves me regardless of how much I try to impress him. Paul Trani Contents at a Glance Contents About the Authors About the Technical Reviewer Acknowledgments Foreword Introduction Chapter 1: Introducing Mobile Flash Chapter 2: Targeting Applications for the Mobile Profile Chapter 3: Building Flash and Flex Applications for Android Chapter 4: Graphics and Animation Chapter 5: Application Deployment and Publication Chapter 6: Adobe AIR and Native Android Apps Chapter 7: Taking Advantage of Hardware Inputs Chapter 8: Rich Media Integration Chapter 9: The Designer-Developer Workflow Chapter 10: Performance Tuning Chapter 11: Beyond Mobile: Tablets and TV Index Contents Contents at a Glance About the Authors About the Technical Reviewer Acknowledgments Foreword Introduction Chapter 1: Introducing Mobile Flash Why Android? Flash on Other Platforms Exploring Android The Flash Platform The Flash Runtime Flash Tooling Running Applications from Flash Professional Running Applications from Flash Builder Running Applications from the Command Line Summary Chapter 2: Targeting Applications for the Mobile Profile Screen Size Screen Resolution vs. Density Simulating Device-Independent Pixels in Flash Density in Flex Applications Density Explorer Application Density Support in CSS Screen Orientation Portrait/Landscape Switching in Flex Automatic Orientation Flipping in Flash Rotating Smiley Flash Orientation Example Multitouch and Gestures Mobile Gestures Flash Scrapbook Example Touch Point API Summary Chapter 3: Building Flash and Flex Applications for Android Constructing Mobile UIs with Flex ViewNavigatorApplication Important Events in the Life of a View TabbedViewNavigatorApplication Just an Application ViewNavigator and Views Passing Data Between Views Persisting View and Session Data Visual Controls Text Controls Soft Keyboard Support Button Controls Flex Lists Slider, Scroller, and BusyIndicator Controls Summary Chapter 4: Graphics and Animation Using Spark Primitives for 2D Shapes Drawing Rectangles and Ellipses Using Linear and Radial Gradients Rendering Cubic Bezier Curves Another Path Element Example Using Spark Filters Applying Transformations to Geometric Shapes Creating Scaled Effects Creating Animation Effects in Spark Using the Animate Element Animation: Parallel and Sequence Creating 3D Effects Creating Spark Skins Generating 2D Charts and Graphs in Spark Creating 2D Bar Charts Creating 2D Pie Charts Using FXG with Spark A Sketching Program Summary Chapter 5: Application Deployment and Publication Setting Up an Android Emulator Installing the Android SDK Creating an Android Virtual Device Installing AIR Within the Emulator Emulator Key Bindings Deploying AIR Applications Setting Up ADT Application Permissions Icons and Resources Code Signing Certificates Creating Certificates Using ADT Publishing from Flash Professional Exporting Release Builds from Flash Builder Running Flex Applications in the Android Emulator Deploying from the Command Line Publishing AIR Apps to Android Market Step 1: Create an Android Market Developer Account Step 2: Package Your Application Step 3: Upload Your Adobe AIR Application Publishing AIR Apps to the Amazon Appstore Summary Chapter 6: Adobe AIR and Native Android Apps Invoking URI Handlers in Adobe AIR Launching Custom HTML Pages in Adobe AIR Navigating to HTML Pages in Adobe AIR Accessing SQLite in Adobe AIR Learning Basic Concepts in Android Major Features of Android 3.0 Download/Installation of Android Key Concepts in Android Creating Android Applications The Structure of an Android Application The Main Files in an Android Application Sending Notifications in Android Applications Adobe AIR and Native Android Integration Summary Chapter 7: Taking Advantage of Hardware Inputs Microphone Camera and CameraUI Camera Manipulating the Camera's Video Stream CameraRoll CameraUI Accelerometer The Accelerometer and AccelerometerEvent Classes Geolocation Summary Chapter 8: Rich Media Integration Playing Sound Effects The SoundEffect Class Embedded SoundEffect Example Sophisticated Sound Solutions Playing Recorded Sound Generating Sound Data on the Fly Handling the State Transitions A Flash Music Player Playing MP3 Files From Prototype to Application Playing Video Optimizing Video for Mobile Devices Spark VideoPlayer Video with NetStream Playing Video with OSMF VideoRecorder Example Summary Chapter 9: The Designer-Developer Workflow The Visual Designer's Role Starting in Adobe Device Central Using Device Central Adobe Photoshop Graphic File Formats Adobe Illustrator Adobe Fireworks The Developer's Role The Developer's Toolbox Summary Chapter 10: Performance Tuning Mobile Performance Tuning Basics
Description: