Professional Documents
Culture Documents
by Vronique Brossier
Copyright 2011 Vronique Brossier. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (http://my.safaribooksonline.com). For more information, contact our
corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com.
Printing History:
May 2011:
First Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the OReilly logo are registered trademarks of
OReilly Media, Inc. Developing Android Applications with Adobe AIR, the image of a Royal Flycatcher,
and related trade dress are trademarks of OReilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and OReilly Media, Inc., was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors assume
no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
ISBN: 978-1-449-39482-0
[LSI]
1303389007
Table of Contents
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
1. AIR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Installing the Adobe Development Tools
Flash Professional CS5.5
Flash Builder 4.5
Installing the AIR Runtime on an Android Device
What Is in the AIR SDK
New ActionScript Libraries
Functionalities Not Yet Supported
AIR on the Desktop Versus AIR on Android
Mobile Flash Player 10.1 Versus AIR 2.6 on Android
2
2
2
2
3
4
5
5
6
8
8
8
9
9
9
9
10
11
12
12
12
13
13
vii
13
14
15
15
15
15
16
16
16
18
3. Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Android Software Development Kit
Installing the Android SDK
Installing the Android Debug Bridge
Detecting Your Device
Using the Dalvik Debug Monitor
Using the logcat Command
Using the Virtual Device Manager and Emulator
How Does AIR Run on Android?
Starting AIR with intent
AIR Access to Android APIs
Using the Command-Line Tool
A Basic Review
Conclusion
20
20
21
22
22
23
24
25
25
26
27
27
28
29
30
30
31
33
36
36
37
38
38
38
38
39
39
40
40
41
41
41
41
42
43
45
46
46
46
46
46
47
47
48
48
49
50
51
54
54
55
55
58
58
58
59
61
61
62
63
65
66
70
76
77
77
Table of Contents | ix
7. Multitouch Technology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
A Brief History
What Is Multitouch and Gesture?
How Does It Work?
The Multitouch Class
The GestureEvent Class
The Zoom Gesture
The Rotate Gesture
The Pan Gesture
The Swipe Gesture
The Press and Tap Gesture
The Two-Finger Tap Gesture
The TouchEvent Class
The GestureWorks Library
Designing for Touch
Conclusion
79
80
80
81
82
82
83
85
86
87
88
88
91
91
92
8. Accelerometer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
What Is a Motion Sensor?
The Accelerometer Class
Visualizing the Values
A Simple Animation
Updates and Screen Rendering
Setting Boundaries
Rotating Toward the Center
Shake Me
Smoothing Out Values
Conclusion
93
93
95
95
96
97
98
99
100
102
9. Camera . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
The Gallery Application and the CameraRoll Class
Selecting an Image
Adding an Image
The Camera Application and the CameraUI Class
Uploading to a Remote Server
EXIF Data
Conclusion
103
104
109
109
111
111
114
115
117
118
Using GPS
Using the Cellular Network and WiFi
How to Know if GPS or WiFi Is Active
AIR and Android
Reverse Geocoding
Maps
Launching Google Maps
Static Maps
Dynamic Maps
EXIF Data and the Map Object
The speed Property
Conclusion
119
119
120
121
122
124
124
125
129
132
134
134
137
138
139
140
144
144
144
145
147
147
149
149
150
151
151
152
152
152
152
154
154
158
158
161
161
163
163
Table of Contents | xi
Resolution
Performance
Playing Video
Embedded Video
External Video
Progressive Video
RTMP Streaming
HTTP Dynamic Streaming
Peer-to-Peer Communication
Controls
YouTube
Capturing Video
Video and the CameraUI Class
The Camera Class
Documentation and Tutorials
Conclusion
163
164
164
165
165
165
169
171
171
171
172
172
172
175
176
176
177
178
180
181
182
184
185
185
187
188
189
189
189
190
190
190
193
195
195
196
196
198
198
199
199
199
200
200
200
201
202
202
203
203
205
206
208
210
210
212
213
215
217
218
219
219
220
220
221
221
225
232
234
237
239
240
240
240
243
244
Table of Contents | xiii
Images
Audio
Reverse Geolocation
SQLite
P2P Connection
Scrolling Navigation
Desktop Functionality
Conclusion
244
244
244
244
245
245
248
249
251
251
252
252
254
254
255
255
255
255
256
256
257
259
259
261
261
261
262
263
265
266
266
266
267
267
267
269
270
270
272
Events
Event Propagation
One Listener for Many Children
Generic and Custom Events
Diagnostics Tools
Hi-Res-Stats
Flash Builder Profiler
Flash Preload Profiler
Grant Skinners PerformanceTest
Native Tools
Conclusion
273
274
275
276
277
277
278
279
279
279
279
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
Table of Contents | xv