CONTENTS

INTRODUCTION

Chapter 1: Flash Is Mobile

Mobile Devices

The Mobile Ecosystem

Participants

Recommended Reading

Engaging Experiences That Work on Small Screens

What Is Flash Lite?

Past, Present, and Future

The Open Screen Project

Multiple Devices and Platforms

OEMs Supporting Flash Lite Player Development

Types of Flash Lite Mobile Content

Flash Lite Architecture

Flash Lite Player 3.x Features

Summary

Chapter 2: Getting Started

Developing for Flash Devices

What You Will Need

Using Device Central

What Are Device Sets?

Using the Online and Local Libraries

Understanding Device Profiles

Creating Device Sets

Comparing Device Profile Information

Creating New Flash Mobile Documents

Creating a “Hello World” Example

Using the Emulator in Device Central

Memory and Device CPU

Testing on Mobile Devices

Devices with Flash Lite Pre-Installed

Remote Devices

Summary

Chapter 3: Object-Oriented Programming for Flash Lite Development

AS2 Revisited

Object-Oriented Programming for Flash Lite

Why OOP?

An OOP Example for Mobile

Mobile Device Considerations

Using fscommands to Communicate with the Device

Using Device Capabilities

System.capabilities

Events and Event Listeners

Using the EventDispatcher Class

Keys, Buttons, and Touch Input

Using the Key Class

Using the ExtendedKey Class

Handling Touch Interaction

Summary

Chapter 4: UI Components

Sony Ericsson and Forum Nokia Component Libraries

Using Text

Using Buttons

UI Component States

Using the Component Inspector

Using Soft Keys

Using Status Bar

Using Title

Using Check Boxes

Using Radio Buttons

Using Lists

Creating a Single Row List

Using Modal Dialogues

Using Visual Indicators

The Progress Indicator

The Wait Indicator

Using Sliders

Using Scrollable Areas

Using the Scrollable Area Component

Using the Scrollable Text Component

Using Notification

Summary

Chapter 5: PureMVC ActionScript 2.0 framework

Design Patterns and Development Frameworks

Time for a Development Framework

Design Patterns Used in PureMVC

PureMVC Key Concepts Explained

The Facade

Notifications and the Observer

Commands and the Controller

Mediators and The View

Proxies and the Model

Building a PureMVC Example

Creating a Model for the Example app

Creating the Example App’s Controller

Exploring the View

Viewing the Application in Device Central

Summary

Chapter 6: Creating a TV Listings Application

The Concept

TV Genius Search Engine API

Mandatory Search Parameters

Optional Search Parameters

Response Format for an API Call

Functional Requirements

Building the Application

The .fla File

Defining ApplicationFacade

Creating a Model for the TV Listings Application

Using XML Data

Creating the TV Listings Application’s Controller

Exploring the View

Viewing the Application in Device Central

Security Considerations: Loading Data

The crossdomain.xml File

Setting the Sandbox Type

Setting the Playback Security

Summary

Chapter 7: Creating a Media Console

The Core Media Classes

Using NetConnection

Using NetStream

Using the Video Object

Using the Sound Object

Streaming Audio and Video

Streaming FLV Video

Streaming MP3 Audio

System.capabilities Revisited

Building the Application

The .fla File

Defining ApplicationFacade

Creating a Model for the Media Console

Creating the Media Console’s Controller

Exploring the View’s Mediators

Viewing the Application in Device Central

Summary

Chapter 8: Creating an Image Viewer Client

The Challenges

Supported Images

Loading Multiple Images

Memory Considerations

Handling Image Sizes

Components Used in the Image Viewer

MovieClipLoader

The SharedObject Class

Building the Application

The .fla File

Defining ApplicationFacade

Creating a Model for the Image Viewer

Exploring the View

Creating the Image Viewer’s Controller

Viewing the Application in Device Central

Summary

Chapter 9: Creating a Twitter Client

Exploring the Twitter API

Twitter Fundamentals

Twitter API Methods

The SWX Format

What Is SWX?

User Timeline

Building the Application

The .fla File

Defining ApplicationFacade

Creating a Model for the Twitter Client

Creating the Twitter Client’s Controller

Exploring the View

Viewing the Application in Device Central

Summary

Chapter 10: Using Nokia’s S60 Platform Services API

S60 Platform Services Overview

Download and Install the Library

How to Use the API Methods

Using AppManager

API Features

Using Calendar

API Features

Using Contacts

API Features

Using Landmarks

API Features

Using Location

API Features

Using Messaging

API Features

Using Media Management

API Features

Other S60 Platform Services

ActionScript Sensor Service API

ActionScript Logging Service API

ActionScript SystemInfo Service API

Summary

Chapter 11: Creating a Weather Client

Google APIs

Using Google Weather API

Weather Conditions

Forecast_Information

Using Google Map API

Wireframes and Design

Building the Application

The .fla File

Defining ApplicationFacade

Creating a Model for the Weather Client

Creating the Weather Client’s Controller

Exploring the View

Viewing the Application in Device Central

Summary

Chapter 12: Using Sony Ericsson’s Project Capuchin Platform Services API

Project Capuchin Platform Services Overview

Project Capuchin API Services

How to Use the API Methods

Using Accelerometer

API Features

Testing the API in Device Central

Using Bluetooth

API Features

Using Calendar

API Features

Using Contacts

API Features

Using File

API Features

Using I18n

API Features

Using Messaging

API Features

Using Persistency

API Features

Using Radio

API Features

Other Project Capuchin Services

Location

Multimedia

Summary

Chapter 13: Packaging Flash Lite Applications for Distribution

Packaging Content

Packaging for Different Platforms

Using Swf2Jar

Creating a .jar File

Creating a .sis File

Obtaining a Unique Identifier (UID)

Creating the Package (PKG) File

Using makesis.exe

Application Signing

Certificates

Untrusted Content

Using makekeys.sis

Using signsis.exe

Signing for Windows Mobile

Signing for Symbian S60

Signing for Java

Signing Programs

Publishing to Aggregators

Application Icons

Using mifconv.exe

Using epocrc.exe

Nokia Flash Packaging Tool

Introducing Ovi from Nokia

The Ovi Store

Introducing PlayNow Arena from Sony Ericsson

Sony Ericsson Content Submission

Summary

Appendix: Flash Lite 3.X Actionscript 2.0 Quick Reference: From Array to Xmlsocket

Index

Professional Flash® Lite® Mobile Development

Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.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 specifically disclaim all warranties, including without limitation warranties of fitness 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 affiliates, 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.

For Joanna and Olivia.

CREDITS

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 Wakefield

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

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 intensified after winning the “Best Productivity” category for his mobile TV guide concept in the first 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 Sheffield Hallam University.

ACKNOWLEDGMENTS

WRITING THIS BOOK WAS TRULY A LABOR OF LOVE during the many days and late nights spent putting it together. Time flew, 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

INTRODUCTION

WITH THE RECENT EXPLOSION OF MOBILE APPLICATIONS and app stores, there has never been a better time for developers to begin creating content for Flash-enabled mobile devices. With many of the leading device manufacturers supporting Flash Lite, there are lots of opportunities for existing Flash developers to get their content into the hands of mobile consumers. The wide consumer reach of Flash-enabled devices is what also makes Flash Lite a very attractive route for both new and experienced application developers to begin developing mobile content.

Professional Flash Lite Mobile Development covers a variety of advanced topics for developing Flash mobile content, with the core focus on developing applications.

This book gives extensive code examples detailing how to create several Flash Lite mobile applications from the ground up utilizing Web service APIs, images, video, and audio. The book has great appeal for anybody wanting to monetize and showcase their mobile content on a global scale.

WHO SHOULD USE THIS BOOK

Programmers and developers of all experiences will be able to use the book as a reference on how to build content for mobiles and devices using Adobe Flash Lite, from concept to completion.

This book is aimed primarily at mobile developers looking to create and distribute new Flash mobile applications using Flash Lite.

This book is also designed to help newcomers and experienced mobile developers in Flash and other platforms get the most out of Flash Lite, and also provide those looking to create mobile applications with a solid base and framework concepts, which they can apply to future iterations of the Flash technology.

WHAT THIS BOOK COVERS

Professional Flash Lite Mobile Development introduces advanced topics, covering the key aspects of Flash Lite mobile development:

It guides the reader through a series of code samples and example applications that explore cool concepts, best practices, and the core features of the Flash Lite player.

It introduces the PureMVC framework as the basis for structuring the core example applications, familiarizing the reader with well-structured object-oriented programming with ActionScript.

It goes beyond the boundaries of the Flash Lite player, exploring the platform APIs of two of the leading mobile device manufacturers supporting Flash Lite and Flash-enabled devices.

It provides details and best practices on how to package and distribute Flash Lite applications.

Chapter-by-Chapter Description

A description of each chapter follows:

Chapter 1 — Flash Is Mobile: This chapter provides a brief discussion of mobile devices and Flash, as well as its role in the mobile ecosystem, and a look at Flash Lite and what it is. It also takes a retrospective look at the iterations of Flash Lite and then covers the core features of the technology that the reader explores throughout the book.

Chapter 2 — Getting Started: This chapter focuses on getting started with Flash Lite mobile development, taking a look at the two essential tools used in developing and testing Flash mobile and device content: Adobe Flash CS4 Professional and Adobe Device Central CS4.

Chapter 3 — Object-Oriented Programming for Flash Lite Development: This chapter includes an overview of ActionScript 2.0, and common object-oriented programming concepts that can be used in coding Flash Lite applications. It also covers language elements specific to Flash Lite mobile development.

Chapter 4 — UI Components: This chapter explores the excellent Sony Ericsson UI component library used for developing Flash Lite user interfaces. Many of these components are used throughout the book.

Chapter 5 — PureMVC ActionScript 2.0 Framework: This chapter provides an in-depth look at PureMVC and the several development concepts and frameworks that can be used to structure code for Flash Lite applications.

Chapter 6 — Creating a TV Listings Application: This chapter takes a detailed and hands-on approach to developing a TV listings application.

Chapter 7 — Creating a Media Console: This chapter provides detailed insight into, and approaches to, developing rich audio and video Flash Lite applications.

Chapter 8 — Creating an Image Viewer: This chapter covers aspects of using images in Flash Lite and provides a detailed walkthrough of an image application.

Chapter 9 — Creating a Twitter Client: This chapter introduces the Twitter API and SWX format, and then explores the code behind a Flash Lite Twitter application from the ground up.

Chapter 10 — Using Nokia’s S60 Platform Services API: Takes an in-depth look at extending Flash Lite mobile applications beyond the features of the Flash Lite player, using the S60 Platform Services API from Nokia.

Chapter 11 — Creating a Weather Client: Following on from the S60 Platform Services API, this covers design and development of a Weather Client, a location-based service application that uses a combination of the mobile device hardware, and the Google Maps and Google Weather APIs, to retrieve the latest weather forecast.

Chapter 12 — Using Sony Ericsson’s Project Capuchin Platform Services API: Takes an in-depth look at using the Project Capuchin Platform Services API from Sony Ericsson, allowing the reader to extend Flash Lite mobile applications beyond the features of the Flash Lite player.

Chapter 13 — Packaging Flash Lite Applications for Distribution: Covers how to package completed Flash Lite mobile applications for consumers, introduces aggregators, and the Sony Ericsson and Nokia content distribution channels.

Appendix — Flash Lite 3.x ActionScript 2.0 Quick Reference: From Array to XMLSocket: Provides a handy reference for all the class methods, properties, operators, and events that are found in ActionScript.

HOW THIS BOOK IS STRUCTURED

While each chapter of the book follows on from one to the other, the book is written in such a way that it allows the reader to pick up and start from any chapter.

I recommend reading Chapter 5 before tackling the code examples, as Chapter 5 provides the background for the code examples in Chapter 6 through to 9, and Chapter 12.

Every other chapter in the book can be read in isolation.

WHAT YOU NEED TO USE THIS BOOK

You will need to have one of the following operating systems:

Windows, Mac or Linux

To use the code samples and run the example applications in this book you will need the following:

Adobe Flash CS4 Professional

Adobe Device Central CS4

Adobe Extensions Manager

You do not explicitly need a Flash Lite-enabled mobile device to complete the applications in the book.

CONVENTIONS

To help you get the most from the text and keep track of what’s happening, we’ve used a number of conventions throughout the book.

Boxes with a warning icon like this one hold important, not-to-be forgotten information that is directly relevant to the surrounding text.

The pencil icon indicates notes, tips, hints, tricks, or asides to the current discussion.

As for styles in the text:

We highlight new terms and important words when we introduce them.

We show keyboard strokes like this: Ctrl+A.

We show file names, URLs, and code within the text like so: persistence.properties.

We present code in two different ways:

We use a monofont type with no highlighting for most code examples.
We use bold to emphasize code that’s particularly important in the present context or to show changes from a previous code snippet.

The example code block gives two lines of code, the one with no highlighting is general code, used in the majority of examples in the book. Whereas the second line has grey highlighting to emphasize the code is important in the present context. Here I’d want you to focus on the text color property _textColor property of the object called statusTitle.

SOURCE CODE

The days when code was small and easily explained in a few written pages are gone. Today, many Flash applications are thousands of lines of code with large supporting libraries. Due to the size of many 3D applications, you no longer have the luxury of showing every line of code that goes behind each application. And in many instances, in this book, after a discussion of how code works the reader is sent to the book’s website to download the entire application for review.

The amount of code written for the book was significant (about 119,000 files) and as the book was written the versions of PV3D and other supporting software changed. So as opposed to trying to keep track of every different version of PV3D, the version of PV3D (and other supporting software) used to create each application was included with each application.

All of the source code used in this book is available for download at http://www.wrox.com. Once at the site, simply locate the book’s title (either by using the Search box or by using one of the title lists), and click the Download Code link on the book’s detail page to obtain all the source code for the book.

Because many books have similar titles, you may find it easiest to search by ISBN; this book’s ISBN is 978-0-470-54748-9.

Once you download the code, just decompress it with your favorite compression tool. Alternately, you can go to the main Wrox code download page at http://www.wrox.com/dynamic/books/download.aspx to see the code available for this book and all other Wrox books.

ERRATA

We make every effort to ensure that there are no errors in the text or in the code. However, no one is perfect, and mistakes do occur. If you find an error in one of our books, like a spelling mistake or faulty piece of code, we would be very grateful for your feedback. By sending in errata, you may save other readers hours of frustration and at the same time you will be helping us provide even higher-quality information.

To find the errata page for this book, go to http://www.wrox.com and locate the title using the Search box or one of the title lists. Then, on the book details page, click the Book Errata link. On this page you can view all errata that has been submitted for this book and posted by Wrox editors. A complete book list including links to each book’s errata is also available at http://www.wrox.com/misc-pages/booklist.shtml.

If you don’t spot “your” error on the Book Errata page, go to http://www.wrox.com/contact/techsupport.shtml and complete the form there to send us the error you have found. We’ll check the information and, if appropriate, post a message to the book’s errata page and fix the problem in subsequent editions of the book.

P2P.WROX.COM

For author and peer discussion, join the P2P forums at http://p2p.wrox.com. The forums are a Web-based system for you to post messages relating to Wrox books and related technologies and interact with other readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts, and your fellow readers are present on these forums.

At http://p2p.wrox.com you will find a number of different forums that will help you not only as you read this book, but also as you develop your own applications. To join the forums, just follow these steps:

1.   Go to http://p2p.wrox.com and click the Register link.

2.   Read the terms of use and click Agree.

3.   Complete the required information to join as well as any optional information you wish to provide, and click Submit.

4.   You will receive an e-mail with information describing how to verify your account and complete the joining process.

You can read messages in the forums without joining P2P but in order to post your own messages, you must join.

Once you join, you can post new messages and respond to messages other users post. You can read messages at any time on the Web. If you would like to have new messages from a particular forum e-mailed to you, click the Subscribe to this Forum icon by the forum name in the forum listing.

For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to questions about how the forum software works as well as many common questions specific to P2P and Wrox books. To read the FAQs, click the FAQ link on any P2P page.

1

Flash Is Mobile

WHAT’S IN THIS CHAPTER?

Developing for mobile devices and small screens

Participants in the mobile ecosystem

Evolution of the Flash Player optimized for mobile devices

Core features and architecture of the Flash Lite Player

As a title for the first chapter in the book I thought I’d pay a little homage to one of the early encounters I had with Flash on mobile devices. The title is actually adopted from the Macromedia marketing header during the launch of Flash Lite 2.0 at Macromedia MAX 2005; there have been other noticeable catchy slogans for Adobe’s mobile and device marketing since then, such as “Engage with Flash,” but here we have a strap line that hits the nail on the head and sets us on our way “Flash Is Mobile…”

Flash has actually been mobile for a number of years now. In order to understand in part how Flash can be utilized on mobile devices, how and where you, the developer, can leverage the technology, in this chapter you’ll take a brief look at the short history and features of Flash Lite Player, the predominant Flash Player runtime used in mobile devices.

MOBILE DEVICES

Since the turn of the century, mobile phones have come a long way from functioning as simple communications devices and today these devices are providing us with everything we need for our daily functions.

Today, mobile devices allow us to listen to our favorite songs, watch recorded video clips and feature films, and record or watch the television shows we have missed. They come with cameras so we can take digital photos and share them with others. We can also use mobiles to play games and, right now, people all over the world are using their mobile devices to send messages, access the Internet, send and receive email, and use various services daily.

“The mobile phone is the first digital device most people look at in the morning, and the last device before going to sleep at night. It is the only digital device many take to the bathroom, and the only one we carry with us all day.”

—TOMI T. AHONEN AND ALAN MOORE, “Communities Dominate Brands”

The possibilities for the mobile device and its applications, right now and beyond, are endless and it is developing mobile applications that is the core focus of this book.

As the underlying technologies used in mobile device handsets have improved, so have the capabilities. In today’s global mobile handset market, consumers have a wide variety of mobile phones to choose from, each with a diverse range of features, aiming to cater for our desires and to make our lives that little bit better.

There are two commonly used terms that categorize the types of mobile phones on the market, the “feature phones” and the “smartphones.” The feature phone is a mobile device with limited or restricted capabilities, where the underlying hardware technology generally tends to be less expensive and at the lower end of the market. Smartphones, on the other hand, are mobile devices with advanced features and capabilities similar to PCs, such as Internet access, and it is this type of mobile device that is becoming more and more popular in the handset market.

For the Flash Lite developer, there is a range of devices that you can target for your applications, and in this book you will focus on developing mobile applications for the smartphone. You’ll cover a wide range of topics relating to Flash Lite mobile application development, through developing a TV Listings Guide, a media Console, an Image Viewer, a Twitter Client, and a Weather Client. All are examples of content that can be consumed by the mobile end user.

Consuming information via a smartphone, anytime, anywhere has never been easier since the introduction of high-speed data networks such as 3G, but some devices are also capable of accessing Wi-Fi networks. But there are several key players involved in ensuring that services and information are delivered to our devices, in a highly competitive, but also thriving, mobile market.

THE MOBILE ECOSYSTEM

Working in the mobile space has its challenges, not just from a developer’s code and development point of view but also for other key participants involved in the mobile ecosystem.

Participants

Figure 1-1 shows the key participants of the mobile ecosystem adapted from Adobe.

The following lists the mobile ecosystem’s key participants, as shown in Figure 1.1; these will be discussed shortly:

Original Equipment Manufacturers (OEMs)

Network operators

Media owners

Content producers

Aggregators

App stores

For each of the key participants mentioned here in the mobile ecosystem, you’ll notice that there is a great deal of overlap in goals, and a need for mobile applications to succeed. Flash offers the distinction from other mobile technologies in that it is capable of running on different platforms.

FIGURE 1-1

OEMs

Original equipment manufacturers (OEMs) manufacture the mobile handsets. They are continually developing new products for the market. They are the innovators responsible for fusing the latest hardware with the software platform that each handset model runs on. The OEMs determine the operating system (OS) used by the device, which can also determine the device’s features and capabilities. OEMs work directly with network operators to ensure that networking hardware is also integrated. For OEMs, it’s imperative to have software on the device that can engage the end user and, essentially, distinguish their products from others in the market.

Network Operators

Network operators manage the network adopted by the consumer. The operators provide the services and channels of content that are accessed by their subscribers. Operators are also known as carriers. They are always looking for ways to improve services to bring more subscribers to their networks.

Media Owners

Media owners effectively own the rights to distribute particular content. Media owners want to be able to distribute their brands to as many domains as possible. Like the OEMs, media owners want to distinguish their brands and ensure that they stand out from the crowd.

Content Producers

Content producers represent the designers and developers who produce mobile content. They often work with the brand guidelines from the media owners to design, develop, and produce mobile content.

Aggregators

Aggregators syndicate and distribute mobile content through online portals and also to the network operators ready for consumption by the consumer. Aggregators were early adopters of syndicating mobile content, who saw great potential of collecting mobile content developed by third-party content producers and distributing it.

App Stores

Unless you’ve been living in a cave for the past year, you know that app stores are where consumers can find content to install on their mobile phones. With devices such as the iPhone, apps, applications, and app stores have been a huge commercial success.

As a Flash mobile developer, the opportunities to generate engaging experiences on mobile phones are vast. Innovative Internet services and applications that require data services are at the heart of the mobile ecosystem and are two of the driving forces behind mobile usage.

Recommended Reading

For a detailed breakdown of the mobile ecosystem, I recommend that you read the Strategy Analytics PDF “Understanding the Mobile Ecosystem” .pdf file found on the Adobe Web site at http://www.adobe.com/devnet/devices/articles/mobile_ecosystem.pdf.

ENGAGING EXPERIENCES THAT WORK ON SMALL SCREENS

Flash has changed the way that people consume and engage with content on the Internet around the world. From animation to video to rich media platforms, today Flash continues to push the boundaries for our digital world and is establishing itself as the platform for the next generation of publishing across multiple screens.

Developing for mobile devices using Flash requires a slightly different train of thought when compared to desktop or Internet browsers:

Screen size — Developing for smaller screens will mean you have to think more inside of the box as well as outside it; in particular, you will need to pay more attention to the detail provided in your applications.

Processing power — With most smartphones having a lower or limited CPU power compared to home PCs, performance measurements need to be taken into consideration.

Interaction and navigation — There is no mouse on a mobile device. The majority of smartphones have keypads; some have touch screens; others have both, which means that, during development, you have to really carefully consider how the end user interacts with the Flash application on the device.

Memory — Ultimately mobile devices tend to have less available memory than desktop computers. Regardless of what Flash applications you develop, they will have an impact on memory, and you will need to be aware of the memory consumed by your applications and the limits to which you can go.

If you are already a mobile developer, then no doubt these issues are already familiar to you, and you know that developing for mobile is not the same as developing for the desktop or Web browsers on personal computers.

What is Flash Lite?

Adobe describes Flash Lite as an “optimized version” of the Flash Player software that is used in PC’s for desktop and Web browsers. The optimized runtime particularly addresses aspects of content running on devices with limited capabilities.

The .swf (SWF) file extension is synonymous with Flash and all versions of the Flash Player, including Flash Lite. The SWF format was introduced in 1998, and the Flash Player is the runtime engine that executes bytecode contained within the .swf files. You’ll be making many a SWF throughout the course of this book.

At the time of writing, there are over 700 types of devices supporting the Flash Player. Flash Lite has been installed on more than one billion devices and can be directly distributed to millions of open OS smartphones.

So what’s the story on Flash Lite?

Past, Present, and Future

In what now seems like “a long time ago in a galaxy far, far away …”, the software company Macromedia (acquired by Adobe) saw the potential of content-rich media on mobile devices. With its early release of Flash Lite in Korea, it achieved its goal of replicating Flash content, produced on personal computers, on other devices, albeit with limited features compared to those on the browser- and desktop-based Flash Player.

The browser-based versions of the Flash Player have always been out of sync with the mobile version, because of the limitations of the device hardware.

Flash Lite 1.x

Flash had already been introduced to Pocket PC devices by the time Flash Lite first appeared as Flash Lite 1.0 on the Japanese NTT DoCoMo i-mode system, which offered mobile Web sites and content such as animations, games, wallpapers, and screensavers for consumers to download over their network. Flash Lite 1.0 was then superseded by Flash Lite 1.1, a release that had a number of enhancements, including network access and integration with the handset.

Flash Lite 1.1, allowed existing Flash developers, who created similar content for Web sites, to leverage their skills. After a few years of progress with Flash on mobile in the Asia Pacific (APAC) region, the Flash Lite 1.1 player made its way to developers in other regions of the world: Europe, the Middle East, and Africa (EMEA); North America, and South America. This iteration of the Flash Lite Player signaled the start of a new dawn for Flash on mobile devices, and as the developer community became more established, licensing agreements were made with OEMs to pre-install the Flash Lite Player on mobile handsets allowing consumers to view compatible content.

Flash Lite 2.x

A few years after the release of 1.1, Flash Lite 2.0 was introduced with performance improvements and new features, including the ability to play both device video and sound, attracting further interest from OEMs and establishing the player as a fully rich media player for the mobile market among its competitors.

Developers from other mobile software development backgrounds, attracted by the ease of using and rapid development possible with 2.0, also found Flash Lite to be a great interactive mobile solution.

The open source application development platform established by Qualcomm BREW (Binary Runtime Environment for Wireless) later was given a slightly different implementation of Flash Lite, in Flash Lite 2.1.

Flash Lite 3.x

Not long ago Flash 3.0 opened up new avenues for Flash on mobile. Fueled in part by a “revolution” in Flash video on the Internet, the more evolved features in version 3.0 meant that the player would allow playback of video directly into the Flash Player, another boost for the multimedia capabilities of the player.

Other features of the player included performance enhancements and the ability to stream media through Adobe Flash Media Server (FMS). More recently Flash Lite 3.1.x became the first iteration of the Flash Lite Player that can be distributed with content created by developers.

This book primarily covers Flash Lite 3.x. There is another version of the Flash Lite Player currently in development that will be backwardly compatible; however, at the time of writing, this is not available to developers.

The Open Screen Project

The Open Screen Project (http://www.openscreenproject.org/) is an industry-wide collaboration to establish a “consistent runtime environment” for experiences across a variety of screens and devices. The initiative recognizes the Adobe Flash platform as the key technology to deliver consistency and provide consumers with the rich experiences they demand, whether in a browser or on the desktop, a mobile device, TV, or a gaming console. This is an ambitious project, one that remains central to Adobe, which leads the initiative, and one that will also be central to the strategies of the majority of content owners in the not too distant future.

Flash Player 10.1

At the time of writing, the next increment of the Adobe Flash Player runtime, Flash Player 10.1, is going through its public beta for developers. This is the first runtime release adopted by the Open Screen Project, which enables Flash content to run across numerous platforms and devices, including mobile. This is the first full Flash player targeted at both mobile devices and PCs; the announcement of the release signals that mobile devices are becoming more powerful, capable of presenting content that matches that of high-end desktop technology.

Flash Lite 3.x content will be supported in both Flash Player 10.1 and the next “unreleased” version of the Flash Lite player, and it is said that devices containing this are soon to be referred to simply as “Flash enabled.”

Multiple Devices and Platforms

Although the sole focus of this book is on developing mobile applications, you should be aware the Flash Lite Player 3.x has been ported to a variety of consumer electronics and numerous platforms, including:

Nokia

Sony Ericsson

HTC

Microsoft

Chumby

iRiver

At the same time that the adoption of Flash Player 10.1 will undoubtedly grow in 2010, the integration of the Flash Lite Player into devices will also continue to grow for a while and is estimated to peak in the billions by the end of 2010.

OEMs Supporting Flash Lite Player Development

Device manufacturers Nokia and Sony Ericsson are among a number of OEMs supporting Flash mobile development, and these two in particular have resources that you can utilize in your Flash development. One of the very early debates among developers during the early release of Flash Lite was whether Flash Lite or Java Platform, Micro Edition (JME) would prevail as the mobile technology of choice. They coexist, and Sony Ericsson has enabled developers to leverage the benefits of both technologies in the Project Capuchin initiative, which has enabled the Flash Player to be bundled in a J2ME wrapper to provide the additional features of a device; this also provides a good crossover between the two software entities. Extending Flash Lite applications with Project Capuchin is covered in Chapter 12.

Types of Flash Lite Mobile Content

One of the challenging aspects of mobile application development is the complexity of devices, operating systems, and capabilities of each device. The key advantage of Flash is that it can run on multiple handsets and operating systems. However, not all content types will support all Flash Lite features; even if the Flash Lite version is the same, there still could be some aspect of Flash Lite that isn’t supported.

Flash Lite content comes under particular categories, including:

Screensavers

Ringtones

Standalone applications

This book contains content specifically created for the standalone versions of Flash Lite.

Adobe Device Central provides a more comprehensive list of content types that you can create using Flash Lite. It also provides the full set of properties and features supported by various mobile device handsets. You’ll learn more about Device Central in Chapter 2.

The aim of each application covered in the book is to provide you with practical solutions for developing a wide range of Flash applications for mobiles devices.

FLASH LITE ARCHITECTURE

In this section, we’ll take a look at the Flash Lite 3.x Player architecture and go over the features that you’ll be covering in the next section.

In Figure 1-2, you can see the overall architecture of the Flash Lite 3.0 player.

FIGURE 1-2

The main aspects of the Flash Lite runtime can be seen as:

Core Rendering Engine

ActionScript 1.1/2.0 Engine

Vector Font Data

SWF Audio, a component enabling audio to play back

Sorenson

JPEG

Device Capabilities

Device Content, Audio, Video, Text, and Image

Persistent Data

Dynamic Data

You’ll cover aspects of the architecture in the next section.

Flash Lite Player 3.x Features

The majority of the Flash Lite Player features shown in the architecture diagram are covered throughout the chapters of this book:

ActionScript 2.0

Device features and capabilities

Loading external resources

Video support

Audio support

Font and text support

Images

Persistent data

Dynamic data and XML support

Flash Lite gives the Flash mobile platform a lot of features, such as ActionScript 2.0 for accessing and controlling device keys and functions, networks and connectivity, audio playback, event and streaming sound, different types of texts, fonts, navigation controls, and images.

ActionScript 2.0

Although ActionScript 3.0 (AS3) has been around for a while now, Flash Lite 3.x fully supports the ActionScript 2.0 (AS2) engine. Based on the ECMA 262 standard, AS2 is a modern programming language that supports dot-syntax and object-oriented development. This book fully covers examples written in AS2.

You’ll cover AS2 development in Chapter 3.

At the time of writing this book, the beta for the Flash Player 10.1 using version AS3 was announced. There is currently no developer edition of Flash Lite that supports AS3.

Device Features and Capabilities

Every mobile device handset has its own particular features and capabilities, implemented by the OEMs. Video playback, sound support, and predictive user input text are all examples of features that may or may not be supported across a different range of mobile devices.

With the Flash Lite 3.x Player, you have ways of determining specifically which features or capabilities are supported by the device dynamically through AS2 properties and functions:

System.capabilities

fscommand() and fscommand2()

Both these functions allow you to target aspects of your applications during development. By using System.capabilities, you can access the properties of the device, such as determining the language. By using fscommands you can access and adjust device features directly from your mobile applications, such as monitoring the battery and network signal levels, sending text messages, making phone calls, altering the device’s backlight, and setting the device to vibrate.

You’ll learn more about accessing device features and capabilities in Chapter 3.

OEMs Nokia and Sony Ericsson also have APIs specifically for developing Flash Lite applications for their supported handsets, which allow you to access more advanced features of their devices and extend your Flash Lite applications. Features such as sending files via Bluetooth, gaining access to the Accelerometer, GPS or the device’s file systems are examples of features which need to be retrieved by the Flash Lite Player.

You’ll learn more about extending Flash Lite applications in Chapters 10 and 11.

Loading External Resources

Network connectivity enables Flash Lite 3.x applications to dynamically load data and resources, that reside externally, into the main SWF application. Multimedia, text-based content, and data objects are all resources supported externally from folders residing on the actual device or from a Web server over HTTP.

You’ll learn more about loading external resources across the chapters in this book.

Audio Support

Flash Lite 3.x supports a range of file formats for audio playback, including MIDI, MP3, Pulse Code Modulation (PCM), Adaptive Differential PCM (ADPCM), and SMAF.

You can embed sounds directly into the Flash Lite application or load them into the application over HTTP or from a location on the device. Streaming audio via RTMP using Adobe Flash Media Server (FMS) is also supported.

You’ll learn all about using sound in your applications in Chapter 7.

Video Support

Flash Video (FLV) is widely regarded as the “most popular video format” on the Internet. Support for FLV via the On2 VP6 and Sorenson video codecs, was one of the key features introduced in Flash Lite 3.0 allowing for the format to be played directly within the Flash Lite Player. The Flash Lite Player for mobile now includes support for H.264, the standard used in high definition (HD) televisions, game consoles, and video players.

Flash Lite also supports video playback of other video formats supported by the majority of mobile devices, including 3GPP and MPEG-4 files.

Video files can be embedded directly into the Flash Lite application, and they can also be loaded into the application externally over a HTTP server or from a location on the device itself at runtime. Delivery of video can also be made over the Real Time Messaging Protocol (RTMP) using media servers such as FMS and Red5.

You’ll learn all about how to include video in your applications in Chapter 7.

Text and Font Support

Developing applications for Flash Lite allows you to include a variety of text components in your applications, including dynamic text fields, text for user input, and static text. Static fields are created during authoring time, whereas dynamic text and input text can be created during authoring time and at runtime.

You also have a choice between using device fonts or embedded fonts. With each choice there is a tradeoff; embedded fonts give you more design control of content but reduce the amount of memory available to the application. Using device fonts gives you less control over design but provide the reassurance that the content will render text.

Flash Lite 3.x supports the UTF-8 character set, including complex languages such as Chinese, Thai, Arabic, and Hebrew. For devices that support the features, Flash Lite also allows predictive text and inline text input. Text measurement and text wrapping are also supported by text fields and device-specific vector fonts for improved small text readability.

Navigation and Keys

The Flash Lite Player also accesses user input events from the device, including the keys for navigation up, down, left, right, and select, and also text, character symbols, and number keys from 0 to 9, *, and #, for example. Figure 1-3 shows an example of device keys supported on the Nokia E71 (from Device Central).

You’ll cover navigation and interaction in Chapter 3.

FIGURE 1-3

Images

Using Flash Lite, you can render image files directly in your applications including PNG, JPEG, and GIF files. You’ll cover including images in your applications in Chapter 8.

Persistent Data

With Flash Lite you can also save data to the device and retrieve it for later use in your applications. You’ll cover saving data in your applications in Chapter 8.

Dynamic Data and XML Support

Also available in Flash Lite 3.x is the ability to load and parse dynamic data, including native classes for loading and parsing of external XML. Several chapters throughout the book cover utilizing dynamic data and parsing XML in particular.

SUMMARY

In this chapter we wanted to give you an overview of the Flash Lite technology and provide a little background as to why the technology is used and where it is headed.

You took a look at the key participants in the mobile ecosystem and also gained insight into various aspects of the Flash Lite architecture, covering the core features of the Flash Lite 3.x Player. You’ve now learned what types of content are supported on devices with the Flash Lite Player installed, and at this stage you should have an idea of what you can develop with Flash Lite. In the upcoming chapters you will learn how to implement many of the features that the player supports, which were highlighted in this chapter.

The next chapter will take you through getting started with Flash Lite development.

2

Getting Started

WHAT’S IN THIS CHAPTER?

Using Adobe Flash CS4 and Device Central CS4 to create new Flash mobile projects

Importing device sets into Device Central CS4

Comparing features across multiple devices in Device Central CS4

Creating a “Hello World” Flash Lite example

Using the Device Central CS4 emulator

Examining the core features of Device Central CS4 to aid in development and testing

Understanding memory and CPU considerations for developing Flash Lite content

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!