Table Of ContentProfessional
flash Mobile DeveloPMent
introDuction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xv
⊲ Part i GettinG starteD
chaPter 1 Introducing Flash Development for Mobile Devices . . . . . . . . . . . . . . . . 3
chaPter 2 Setting Up Your Development Environment . . . . . . . . . . . . . . . . . . . . . . .13
>
m
o chaPter 3 Building and Installing VanillaApp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39
c
k.
o
o
b ⊲ Part ii touch anD user interaction
e
w
wo chaPter 4 Rethinking ActionScript Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
w.
w chaPter 5 Multitouch API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
w
<
k chaPter 6 Detecting Motion with Accelerometer . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
o
o
B
e chaPter 7 Implementing Auto Orientation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
w!
Wo chaPter 8 Geolocation API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
m
o chaPter 9 Service Integration Using URL Protocols . . . . . . . . . . . . . . . . . . . . . . . . . 179
d fr
a chaPter 10 Android Camera, Camera Roll, and Microphone . . . . . . . . . . . . . . . . . .209
o
nl
w
o
D ⊲ Part iii Data
chaPter 11 File Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
chaPter 12 Local Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
⊲ Part iv testinG anD DebuGGinG
chaPter 13 Remote Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
chaPter 14 Submitting Your App to the App Store . . . . . . . . . . . . . . . . . . . . . . . . . .279
aPPenDix a Application Descriptor Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
aPPenDix b Compiling Applications from the Command Line . . . . . . . . . . . . . . . . . . 305
inDex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .309
PROFESSIOnAL
flash® Mobile Development
Creating android™ and iPhone® aPPliCations
Richard Wagner
Professional flash® Mobile Development: creating android™ and iPhone® applications
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2011 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-62007-6
ISBN: 978-1-118-03731-7 (ebk)
ISBN: 978-1-118-03732-4 (ebk)
ISBN: 978-1-118-03733-1 (ebk)
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any
means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections
107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or
authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood
Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should
be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030,
(201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including
without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or pro-
motional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold
with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services.
If professional assistance is required, the services of a competent professional person should be sought. Neither the pub-
lisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to
in this work as a citation and/or a potential source of further information does not mean that the author or the publisher
endorses the information the organization or Web site may provide or recommendations it may make. Further, readers
should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was
written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available
in electronic books.
Library of Congress Control Number: 2010926881
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are
trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other coun-
tries, and may not be used without written permission. Flash is a registered trademark of Adobe Systems, Inc. Android is
a trademark of Google, Inc. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is
not associated with any product or vendor mentioned in this book.
To Kimberly and the boys.
creDits
executive eDitor vice PresiDent anD executive GrouP
Carol Long Publisher
Richard Swadley
Project eDitor
Sydney Jones Argenta vice PresiDent anD executive Publisher
Barry Pruett
technical eDitors
Drew Falkman associate Publisher
Jim Minatel
ProDuction eDitor
Rebecca Anderson Project coorDinator, cover
Katie Crocker
coPy eDitor
Karen Gill coMPositor
Jeff Lytle,
eDitorial Director Happenstance Type-O-Rama
Robyn B . Siesky
ProofreaDer
eDitorial ManaGer nancy Carrasco
Mary Beth Wakefield
inDexer
freelancer eDitorial ManaGer Robert Swanson
Rosemarie Graham
cover DesiGner
MarketinG ManaGer Michael E . Trent
Ashley Zurcher
cover iMaGe
ProDuction ManaGer © Hedda Gjerpen/istockphoto .com
Tim Tate
about the author
richarD WaGner is Lead Product Architect, Web/Mobile at MAARK and author of several Web-
and mobile-related books, including Safari and WebKit Development for iPhone OS 3.0, XSLT For
Dummies, Creating Web Pages All-In-One Desk Reference For Dummies, Web Design Before &
After Makeovers, and more. Richard has also authored several books outside of the field of technol-
ogy, including The Myth of Happiness and The Expeditionary Man.
about the technical eDitor
DreW falkMan has been developing web applications since it was standard practice to test for
Mosaic and Netscape. He rode the dot-com wave through growing a startup and achieving venture
funding, and he is now happy to consult and train through his own company, Falkon Productions.
Over the years, he has architected and worked on sites for customers from startup cattle auctions to
Fortune 500 companies using a host of technologies including Java, ColdFusion, JavaScript, Adobe
Flex/Flash, PHP, and WordPress. Also a writer, Drew has authored two books on Java for Adobe
Press and done technical editing for Que Publishing and Wiley. He has been published in developers’
journals and online, including on Adobe.com. He is an Adobe Certified Instructor and Developer
and has spoken at conferences around the U.S. He currently resides in Santa Monica, CA.
acknoWleDGMents
this WritinG of this book has reflected the stormy seas that Adobe has battled in order to release
Flash and Adobe AIR for mobile platforms. It started off as an iPhone-based book for Flash develop-
ers until Apple infamously changed its terms of use to exclude Packager for iPhone as being a valid way
to create iPhone apps. So, we shifted course, transforming the book into an Android-focused book.
However, when I was about 80 percent done with the writing, Apple changed its restrictive policy on
> Packager for iPhone, opening up Flash development once again to the iOS platform. In response, we
m
changed the focus of the book yet again to account for both Android and iOS devices.
o
c
k.
o On this stormy, but amazing adventure, I was blessed with as good of an editorial team as I have
o
b
e ever had. Major kudos to Sydney Jones Argenta who was project editor. Sydney was diligent, kept
w
o me on track, and always kept things positive and forward-thinking. Also thanks to Drew Falkman
w
w. for his close attention to the technical details as well as many suggestions that improved the quality
w
w of the book. Finally, thanks also to Karen Gill for her editing prowess. It was a joy working with
<
k this amazing group of editors.
o
o
B
e
w!
o
W
m
o
d fr
a
o
nl
w
o
D
Description:Professional Flash Mobile Development: Creating Android and iPhone ApplicationsEverything Flash developers need to know to create native Android and iPhone appsThis Wrox guide shows Flash developers how to create native applications for Android and iPhone mobile devices using Flash. Packed wit