professional flash lite mobile development - buch.de · pdf filechapter 12 using sony...
TRANSCRIPT
![Page 1: Professional Flash Lite Mobile Development - Buch.de · PDF fileCHAPTER 12 Using Sony Ericsson’s Project Capuchin Platform Services API ... (877) 762-2974, outside the United States](https://reader034.vdocuments.mx/reader034/viewer/2022051720/5a78ca0e7f8b9ae6228cfc44/html5/thumbnails/1.jpg)
Jermaine G. Anderson
Professional
Build Flash Applications for Mobile Devices
Flash® Lite® Mobile Development
Wrox Programmer to Programmer™Join the discussion @ p2p.wrox.com
![Page 2: Professional Flash Lite Mobile Development - Buch.de · PDF fileCHAPTER 12 Using Sony Ericsson’s Project Capuchin Platform Services API ... (877) 762-2974, outside the United States](https://reader034.vdocuments.mx/reader034/viewer/2022051720/5a78ca0e7f8b9ae6228cfc44/html5/thumbnails/2.jpg)
Get more out of wrox.com
Programmer to Programmer™
InteractTake an active role online by participating in our P2P forums @ p2p.wrox.com
Wrox Online LibraryHundreds of our books are available online through Books24x7.com
Wrox Blox Download short informational pieces and code to keep you up to date and out of trouble!
Join the CommunitySign up for our free monthly newsletter at newsletter.wrox.com
BrowseReady for more Wrox? We have books and e-books available on .NET, SQL Server, Java, XML, Visual Basic, C#/ C++, and much more!
Contact Us. We always like to get feedback from our readers. Have a book idea? Need community support? Let us know by e-mailing [email protected]
![Page 3: Professional Flash Lite Mobile Development - Buch.de · PDF fileCHAPTER 12 Using Sony Ericsson’s Project Capuchin Platform Services API ... (877) 762-2974, outside the United States](https://reader034.vdocuments.mx/reader034/viewer/2022051720/5a78ca0e7f8b9ae6228cfc44/html5/thumbnails/3.jpg)
PROFESSIONAL
FLASH® LITE® MOBILE DEVELOPMENT
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvii
CHAPTER 1 Flash Is Mobile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
CHAPTER 2 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13
CHAPTER 3 Object-Oriented Programming for Flash Lite Development . . . . . . . . . 33
CHAPTER 4 UI Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
CHAPTER 5 PureMVC ActionScript 2.0 Framework . . . . . . . . . . . . . . . . . . . . . . . . . . 107
CHAPTER 6 Creating a TV Listings Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
CHAPTER 7 Creating a Media Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
CHAPTER 8 Creating an Image Viewer Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
CHAPTER 9 Creating a Twitter Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
CHAPTER 10 Using Nokia’s S60 Platform Services API . . . . . . . . . . . . . . . . . . . . . . . . 337
CHAPTER 11 Creating a Weather Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
CHAPTER 12 Using Sony Ericsson’s Project Capuchin Platform Services API . . . . . 439
CHAPTER 13 Packaging Flash Lite Applications for Distribution . . . . . . . . . . . . . . . . 485
APPENDIX Flash Lite 3.x ActionScript 2.0 Quick
Reference: From Array to XMLSocket . . . . . . . . . . . . . . . . . . . . . . . . . . .509
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537
![Page 4: Professional Flash Lite Mobile Development - Buch.de · PDF fileCHAPTER 12 Using Sony Ericsson’s Project Capuchin Platform Services API ... (877) 762-2974, outside the United States](https://reader034.vdocuments.mx/reader034/viewer/2022051720/5a78ca0e7f8b9ae6228cfc44/html5/thumbnails/4.jpg)
![Page 5: Professional Flash Lite Mobile Development - Buch.de · PDF fileCHAPTER 12 Using Sony Ericsson’s Project Capuchin Platform Services API ... (877) 762-2974, outside the United States](https://reader034.vdocuments.mx/reader034/viewer/2022051720/5a78ca0e7f8b9ae6228cfc44/html5/thumbnails/5.jpg)
PROFESSIONAL
Flash® Lite® Mobile Development
Jermaine G. Anderson
![Page 6: Professional Flash Lite Mobile Development - Buch.de · PDF fileCHAPTER 12 Using Sony Ericsson’s Project Capuchin Platform Services API ... (877) 762-2974, outside the United States](https://reader034.vdocuments.mx/reader034/viewer/2022051720/5a78ca0e7f8b9ae6228cfc44/html5/thumbnails/6.jpg)
Professional Flash® Lite® Mobile Development
Published byWiley Publishing, Inc.10475 Crosspoint BoulevardIndianapolis, IN 46256www.wiley.com
Copyright © 2010 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-54748-9
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 specifi cally disclaim all warranties, including without limitation warranties of fi tness for a particular purpose. No warranty may be created or extended by sales or promotional 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 publisher 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: 2009939787
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 affi liates, in the United States and other countries, and may not be used without written permission. Flash Lite is a registered trademark of Adobe Systems Incorporated. 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.
![Page 7: Professional Flash Lite Mobile Development - Buch.de · PDF fileCHAPTER 12 Using Sony Ericsson’s Project Capuchin Platform Services API ... (877) 762-2974, outside the United States](https://reader034.vdocuments.mx/reader034/viewer/2022051720/5a78ca0e7f8b9ae6228cfc44/html5/thumbnails/7.jpg)
For Joanna and Olivia.
![Page 8: Professional Flash Lite Mobile Development - Buch.de · PDF fileCHAPTER 12 Using Sony Ericsson’s Project Capuchin Platform Services API ... (877) 762-2974, outside the United States](https://reader034.vdocuments.mx/reader034/viewer/2022051720/5a78ca0e7f8b9ae6228cfc44/html5/thumbnails/8.jpg)
ACQUISITIONS EDITOR
Scott Meyers
PROJECT EDITOR
Kenyon Brown
TECHNICAL EDITOR
Darren Osadchuk
PRODUCTION EDITOR
Kathleen Wisor
COPY EDITORS
Eric Newman
Foxxe Editorial Services
EDITORIAL DIRECTOR
Robyn B. Siesky
EDITORIAL MANAGER
Mary Beth Wakefi eld
MARKETING MANAGER
David Mayhew
PRODUCTION MANAGER
Tim Tate
VICE PRESIDENT AND EXECUTIVE
GROUP PUBLISHER
Richard Swadley
VICE PRESIDENT AND EXECUTIVE PUBLISHER
Barry Pruett
ASSOCIATE PUBLISHER
Jim Minatel
PROJECT COORDINATOR, COVER
Lynsey Stanford
PROOFREADER
Nate Pritts, Word One
INDEXER
Robert Swanson
COVER DESIGNER
Mike Trent
COVER IMAGE
iStockPhoto
CREDITS
![Page 9: Professional Flash Lite Mobile Development - Buch.de · PDF fileCHAPTER 12 Using Sony Ericsson’s Project Capuchin Platform Services API ... (877) 762-2974, outside the United States](https://reader034.vdocuments.mx/reader034/viewer/2022051720/5a78ca0e7f8b9ae6228cfc44/html5/thumbnails/9.jpg)
ABOUT THE AUTHOR
JERMAINE G. ANDERSON has been programming for the past 10 years, specializing in Flash and, more recently, the Flex framework. His work predominantly centers on video streaming, and producing on-demand and live video content for the sports and entertainment industries where he has created web components and rich consumer products using Adobe Flash, Flex, and AIR. In 2004, he became interested in Flash mobile applications; this was intensifi ed after winning the “Best Productivity” category for his mobile TV guide concept in the fi rst ever Macromedia Flash Lite 1.1 contest
in 2005. He has since spent time working for UK mobile phone operator T-Mobile, where he created dynamic user interfaces and prototypes using Flash Lite. He has managed an international team of developers and now works for leading entertainment and communications company British Sky Broadcasting. He holds a BSc (Hons) in Chemistry from the University of Birmingham, and an MSc in Computer Studies from Sheffi eld Hallam University.
![Page 10: Professional Flash Lite Mobile Development - Buch.de · PDF fileCHAPTER 12 Using Sony Ericsson’s Project Capuchin Platform Services API ... (877) 762-2974, outside the United States](https://reader034.vdocuments.mx/reader034/viewer/2022051720/5a78ca0e7f8b9ae6228cfc44/html5/thumbnails/10.jpg)
ACKNOWLEDGMENTS
WRITING THIS BOOK WAS TRULY A LABOR OF LOVE during the many days and late nights spent putting it together. Time fl ew, and before I knew it, the days had turned into weeks, and the weeks had turned into months. The end result is something that I am really proud of.
None of this would have been possible without the support of everyone at Wiley, who I’d like to give a big thank you! Thank you all for the time and effort spent making things happen.
I’d like to give special thanks to Scott Meyers, Acquisitions Editor, and Kenyon Brown, Project Editor, for driving the project. Thank you for the belief, guidance, and words of encouragement that were given throughout. Also, thank you to Darren Osadchuk, Technical Editor, for his technical advice and all important feedback.
I’d also like to thank the development team at Sony Ericsson — Velimir Karadzic, Enrique Garcia, and Youness Ghanim — who gave some of their time to review and give feedback.
Finally, many thanks to all my family and friends, for the love and support they gave me during the time of writing. I couldn’t have done it without them, especially my darling wife, Joanna.
—Jermaine G. Anderson
![Page 11: Professional Flash Lite Mobile Development - Buch.de · PDF fileCHAPTER 12 Using Sony Ericsson’s Project Capuchin Platform Services API ... (877) 762-2974, outside the United States](https://reader034.vdocuments.mx/reader034/viewer/2022051720/5a78ca0e7f8b9ae6228cfc44/html5/thumbnails/11.jpg)
CONTENTS
INTRODUCTION xvii
CHAPTER 1: FLASH IS MOBILE
Mobile Devices 1
The Mobile Ecosystem 2
Participants 2
Recommended Reading 4
Engaging Experiences That Work on Small Screens 4
What Is Flash Lite? 5
Past, Present, and Future 5
The Open Screen Project 6
Multiple Devices and Platforms 7
OEMs Supporting Flash Lite Player Development 7
Types of Flash Lite Mobile Content 7
Flash Lite Architecture 8
Flash Lite Player 3.x Features 9
Summary 12
CHAPTER 2: GETTING STARTED
Developing for Flash Devices 13
What You Will Need 14
Using Device Central 15
What Are Device Sets? 15
Using the Online and Local Libraries 16
Understanding Device Profi les 16
Creating Device Sets 17
Comparing Device Profi le Information 18
Creating New Flash Mobile Documents 21
Creating a “Hello World” Example 23
Using the Emulator in Device Central 26
Memory and Device CPU 27
Testing on Mobile Devices 30
Devices with Flash Lite Pre-Installed 31
Remote Devices 31
Summary 31
![Page 12: Professional Flash Lite Mobile Development - Buch.de · PDF fileCHAPTER 12 Using Sony Ericsson’s Project Capuchin Platform Services API ... (877) 762-2974, outside the United States](https://reader034.vdocuments.mx/reader034/viewer/2022051720/5a78ca0e7f8b9ae6228cfc44/html5/thumbnails/12.jpg)
x
CONTENTS
CHAPTER 3: OBJECT-ORIENTED PROGRAMMING FOR FLASH LITE DEVELOPMENT
AS2 Revisited 33
Object-Oriented Programming for Flash Lite 35
Why OOP? 35
An OOP Example for Mobile 35
Mobile Device Considerations 47
Using fscommands to Communicate with the Device 47
Using Device Capabilities 60
System.capabilities 61
Events and Event Listeners 64
Using the EventDispatcher Class 64
Keys, Buttons, and Touch Input 68
Using the Key Class 68
Using the ExtendedKey Class 71
Handling Touch Interaction 72
Summary 74
CHAPTER 4: UI COMPONENTS
Sony Ericsson and Forum Nokia Component Libraries 76
Using Text 77
Using Buttons 77
UI Component States 78
Using the Component Inspector 78
Using Soft Keys 82
Using Status Bar 83
Using Title 84
Using Check Boxes 84
Using Radio Buttons 87
Using Lists 90
Creating a Single Row List 90
Using Modal Dialogues 96
Using Visual Indicators 98
The Progress Indicator 98
The Wait Indicator 100
Using Sliders 100
Using Scrollable Areas 102
Using the Scrollable Area Component 102
Using the Scrollable Text Component 103
Using Notifi cation 104
Summary 105
![Page 13: Professional Flash Lite Mobile Development - Buch.de · PDF fileCHAPTER 12 Using Sony Ericsson’s Project Capuchin Platform Services API ... (877) 762-2974, outside the United States](https://reader034.vdocuments.mx/reader034/viewer/2022051720/5a78ca0e7f8b9ae6228cfc44/html5/thumbnails/13.jpg)
xi
CONTENTS
CHAPTER 5: PUREMVC ACTIONSCRIPT 2.0 FRAMEWORK
Design Patterns and Development Frameworks 107
Time for a Development Framework 107
Design Patterns Used in PureMVC 109
PureMVC Key Concepts Explained 111
The Facade 111
Notifi cations and the Observer 114
Commands and the Controller 116
Mediators and The View 119
Proxies and the Model 125
Building a PureMVC Example 126
Creating a Model for the Example app 128
Creating the Example App’s Controller 132
Exploring the View 134
Viewing the Application in Device Central 136
Summary 136
CHAPTER 6: CREATING A TV LISTINGS APPLICATION
The Concept 139
TV Genius Search Engine API 140
Mandatory Search Parameters 140
Optional Search Parameters 140
Response Format for an API Call 141
Functional Requirements 142
Building the Application 142
The .fl a File 143
Defi ning ApplicationFacade 143
Creating a Model for the TV Listings Application 144
Using XML Data 149
Creating the TV Listings Application’s Controller 158
Exploring the View 165
Viewing the Application in Device Central 174
Security Considerations: Loading Data 175
The crossdomain.xml File 176
Setting the Sandbox Type 176
Setting the Playback Security 176
Summary 177
![Page 14: Professional Flash Lite Mobile Development - Buch.de · PDF fileCHAPTER 12 Using Sony Ericsson’s Project Capuchin Platform Services API ... (877) 762-2974, outside the United States](https://reader034.vdocuments.mx/reader034/viewer/2022051720/5a78ca0e7f8b9ae6228cfc44/html5/thumbnails/14.jpg)
xii
CONTENTS
CHAPTER 7: CREATING A MEDIA CONSOLE
The Core Media Classes 179
Using NetConnection 179
Using NetStream 180
Using the Video Object 184
Using the Sound Object 185
Streaming Audio and Video 190
Streaming FLV Video 190
Streaming MP3 Audio 191
System.capabilities Revisited 192
Building the Application 192
The .fl a File 192
Defi ning ApplicationFacade 193
Creating a Model for the Media Console 196
Creating the Media Console’s Controller 218
Exploring the View’s Mediators 224
Viewing the Application in Device Central 238
Summary 239
CHAPTER 8: CREATING AN IMAGE VIEWER CLIENT
The Challenges 241
Supported Images 242
Loading Multiple Images 242
Memory Considerations 243
Handling Image Sizes 243
Components Used in the Image Viewer 243
MovieClipLoader 244
The SharedObject Class 254
Building the Application 255
The .fl a File 256
Defi ning ApplicationFacade 256
Creating a Model for the Image Viewer 258
Exploring the View 268
Creating the Image Viewer’s Controller 275
Viewing the Application in Device Central 283
Summary 283
CHAPTER 9: CREATING A TWITTER CLIENT
Exploring the Twitter API 286
Twitter Fundamentals 286
Twitter API Methods 288
![Page 15: Professional Flash Lite Mobile Development - Buch.de · PDF fileCHAPTER 12 Using Sony Ericsson’s Project Capuchin Platform Services API ... (877) 762-2974, outside the United States](https://reader034.vdocuments.mx/reader034/viewer/2022051720/5a78ca0e7f8b9ae6228cfc44/html5/thumbnails/15.jpg)
xiii
CONTENTS
The SWX Format 292
What Is SWX? 292
User Timeline 294
Building the Application 298
The .fl a File 299
Defi ning ApplicationFacade 299
Creating a Model for the Twitter Client 300
Creating the Twitter Client’s Controller 316
Exploring the View 322
Viewing the Application in Device Central 336
Summary 336
CHAPTER 10: USING NOKIA’S S60 PLATFORM SERVICES API
S60 Platform Services Overview 337
Download and Install the Library 338
How to Use the API Methods 338
Using AppManager 343
API Features 343
Using Calendar 347
API Features 347
Using Contacts 353
API Features 353
Using Landmarks 360
API Features 360
Using Location 365
API Features 365
Using Messaging 369
API Features 370
Using Media Management 378
API Features 378
Other S60 Platform Services 383
ActionScript Sensor Service API 383
ActionScript Logging Service API 384
ActionScript SystemInfo Service API 384
Summary 384
CHAPTER 11: CREATING A WEATHER CLIENT
Google APIs 385
Using Google Weather API 385
Weather Conditions 388