In this chapter we'll discuss the technology involved in developing mobile applications with the Flash Platform. We'll explore ActionScript, the AIR runtime, and the Flex framework, as well as various best practices for optimizing applications that are to be used on smartphones and tablets.
Developing for the Flash Platform on Mobile
In this lesson, we'll discuss why you might want to develop for mobile devices using Flash Platform technologies and what their main benefits are.
There are various best practices that are good to keep in mind when you get started with mobile application development. In this section we'll look at working with different screen sizes and optimizing performance and user input for touch-based devices.
Best Practices for Mobile
In this lesson, we'll discuss different screen sizes and pixel densities on mobile devices and how to appropriately deal with them in your applications.
This chapter covers the basics of working with mobile in Flash Professional CS5.5. You'll see how to create a new mobile project, work with mobile templates, use the Projects panel, and perform intelligent scaling.
Setting Up Your Project in Flash Professional CS5.5
With Flash Professional CS5.5, you now have the ability to target iOS and Android directly. In this lesson, we'll go over how to create a new project in Flash Professional that targets Android or iOS.
All AIR projects have an application descriptor file, which provides the compiler with certain important project settings. This lesson will explain the importance of the application descriptor file and demonstrate how to access various settings from the Flash GUI.
Mobile devices come in a wide range of screen resolutions and pixel densities. In this lesson, we'll have a look at enhancements made to the Project Panel to allow for shared assets and multiple FLA files targeting specific device resolutions.
Using Flash Professional CS5.5, we can easily adapt objects on our Stage for various mobile device screen resolutions. In this lesson, we'll look at how to modify project resolution in such a way that assets already established upon the stage are able to scale appropriately.
Debugging your mobile application is an essential step in the mobile development process. In this chapter we'll look at what debugging tools are available in Flash Builder 4.5 and how you can do on-device debugging over USB or a wireless network.
Debugging Your Application
In this lesson, we'll look at features that help you debug your application on the desktop, including trace statements, the debugger, and Flash Builder Profiler.
In this chapter we'll cover setting up mobile projects with Flash Builder 4.5 using either ActionScript or Flex 4.5 on mobile. We'll discuss the various project templates available, as well as working with mobile views and data persistence in your application.
Flex Mobile Projects
In this lesson, we'll walk through the process of setting up an ActionScript-based mobile project in Flash Builder 4.5.
Flash Builder lets you set up Flex mobile projects using a number of templates. In this section we'll discuss creating applications that start with a blank, view-based, or tabbed application template. We'll build on that to discuss specific user interface elements available to each of those templates.
Views are the way in which almost all mobile applications are set up. In this chapter you'll see how to set up views in a Flex Mobile View-based application and how to navigate and pass data between them.
Working with Views
In this lesson, we'll look at working with mobile views and how to push a new view in your Flex Mobile view-based applications.
The number of mobile and touch-specific APIs now present in ActionScript 3 is truly staggering. This chapter will introduce you to gestures, touch events, and a variety of hardware APIs and sensors.
Using Mobile API Features
It is possible to enable auto-orientation in an application and respond to device orientation changes through StageOrientationEvent.ORIENTATION_CHANGE. In this lesson, you'll see how to adapt a layout in response to device orientation changes.
Most mobile devices contain an accelerometer sensor that detects movement of the device in space. In this lesson, you'll learn how to adjust the X and Y positions of a display object based on accelerometer sensor data.
The geolocation sensors on a mobile device can be used to gather data and feed that to a variety of external services. In this lesson, we will employ the Geolocation ActionScript API to retrieve dynamic location data that will be fed into the embedded Google Maps API for Flash.
Both Android and iOS have local storage set aside for storing captured photographs. In this lesson, you'll see how to use the CameraRoll API to select an image from device storage and then display the image along with basic metadata within the AIR application.
Many Android devices provide hardware that can be used as a direction control for games or a selection control for applications. This often is part of the device's physical keyboard or can take the form of something like a trackball. In this lesson, you'll learn how to access the D-pad or trackball on an Android device.
Android devices always come with a dedicated set of hardware keys built into the device. These include Back, Menu, Home, and Search. In this lesson, you'll see how to access these keys and override their default behavior.
The rotate gesture involves placing two fingers on the screen and moving one around the other in a clockwise or counterclockwise motion depending on the direction in which one wishes to rotate an object. This lesson looks at using the multitouch rotate gesture.
The Android long-press gesture is a timed touch event that is used heavily on that platform. However, this is not one of the predefined gestures available to us in ActionScript. In this lesson, you'll learn how to simulate the long-press interaction found on Android devices.
When using AIR for Android and iOS, you have a choice of using predefined gestures for your applications or employing raw touch data. In this lesson, we'll look at the data returned when using raw touch interactions in ActionScript.
It is possible to use traditional startDrag and stopDrag methods on mobile as well. In this lesson, you'll see how to use touch points to enable drag-and-drop functionality on display objects in an application.
You can also use AIR for mobile to invoke the native text messenger application on a device. In this lesson, you'll learn how to invoke the native test messaging application (assuming the device is SMS-capable) from within an AIR project.
AIR for mobile enables you to invoke Google Maps through the default web browser or Maps application. In this lesson, you'll see how to invoke the default map application and have it display specific coordinates.
Need to direct a user to email from directly within an AIR application? This lesson will show you how to invoke the native email application from within an AIR project and even pass along some basic information.
On Android, you can link directly to the Android Market from within an AIR application. In this lesson, you'll see how to invoke the Android Market and perform a custom search according to specific parameters.
Working with data is something practically every mobile application does. In this chapter we'll discuss working with the filesystem to read, write, and delete files. We'll also cover setting up and interacting with a local SQLite database as well as interacting and authenticating with online data sources.
Working with Data
Interacting with the filesystem lets you read, write, and delete files on the mobile device you're developing for. In this section you'll see how you can take advantage of these features in your mobile applications.
Interacting with the Filesystem
In this lesson, you'll see how to read in files from the filesystem on mobile devices.
In situations where you have structured data that you want to be able to filter at runtime, local SQLite database support comes in very handy. In this section we'll look at creating a connection to a local database on the mobile device, as well as running queries and getting results back to display in an application.
Working with a Local SQLite Database
This lesson introduces the SQLite database engine and shows how to create and connect to a local database file.
Working with online data sources is very common in mobile applications. In this section you'll see how to do network detection so you can download and cache the latest information as well as work with data returned from an API service call that returns in an XML or JSON format.
Working with an Online Data Source
In this lesson, we'll look at online/offline network detection and caching an online resource on the device for use when no network connection is available.
Open authentication (or OAuth) is an increasingly popular way of authenticating the user in your application with a third-party service. It lets users give applications access to their information without having to share their login and password credentials. In this section we'll discuss how OAuth works and how you can implement it in your projects.
This lesson introduces the basics of open authentication (OAuth), discusses the authentication workflow, and explains what its benefits are.
This chapter will explore working with video, audio, and the StageWebView object on mobile devices. While there is a lot of new stuff to cover with Flash on Android and iOS, it's important to remember that this is still Flash we are working with!
In this section, you'll see how to record, encode, save, load, and play back audio on a mobile device using Adobe AIR.
Working with Audio
In this lesson, you'll learn how to load, play, pause, and resume MP3 playback on a device. This technique is useful for loading full tracks into an application to enable basic playback or for providing background audio to a game.
StageWebView is a totally new object that can be used to render HTML content within an AIR application. In this section, we will look at some of the potential uses for this killer feature.
Working with HTML Using StageWebView
Using AIR for mobile, it is possible to render HTML content in a special object called StageWebView. In this lesson, you'll learn how to load a website into an application using the StageWebView class.
While the StageWebView object is not part of the traditional Flash display list, you can still access the bitmap data of rendered HTML content by using methods specific to this class. In this lesson, you'll see how to capture bitmap data from a StageWebView object by using the drawViewPortToBitmapData method available in ActionScript.
Loading advertisements within a mobile application is a great way to collect a little revenue, even if you're offering an application for free. In this lesson, you'll learn how to employ a StageWebView object to load ads into a mobile application through an ad service.
The final step in making your application publicly available for Apple iOS devices is submitting it to the App Store for distribution. In this chapter we'll discuss the steps involved in doing so, including working with provisioning profiles and exporting a signed release build.
Distributing Applications on iOS
In this lesson, you'll learn how to use the iOS Provisioning Portal to set up certificates, devices, and the App ID for your application.
In this chapter, we will examine how to prepare your AIR for Android application for distribution through the worldwide Android Market. Everything from asset preparation to signing and final publication is covered.
Distributing Applications on the Android Market
The most popular way of distributing Android applications is through the Android Market. In this lesson, you'll see how to register as an Android developer and gain access to the Android Market.
The Android Market requires certain icon files to be compiled along with an .apk to form a valid submission. This lesson demonstrates how to prepare and assign icons for applications that are to be distributed via the Android Market.
Users often appreciate being able to move an application to the device's SD card to save memory. In this lesson, you'll learn how to enable an AIR for Android application to be installed onto the device SD card.
To form a valid submission, the Android Market requires an .apk to be signed with a digital code signing certificate that has certain precise properties. In this lesson, you'll see how to do this correctly and avoid trouble with your submission.
The Android Market requires a number of textual descriptions and image assets to be entered as part of a valid submission. In this lesson, you'll see how to prepare the various assets and data that must accompany your Android application when you submit to the Android Market.
This chapter will examine some of the things that you can do to monitor your application's CPU and memory usage and make sure it behaves properly when installed on a user's device. We'll also look at using an analytics package to track user views and interactions.
Optimizing Your Applications
To be a good steward of system resources, our applications should always free up system memory when not in use. In this lesson, we'll demonstrate how to properly exit an application so as not to take system resources unnecessarily.
When an AIR application is actually run on a device, you can gather information from the device itself to inform certain application runtime decisions. In this lesson, you'll see how to detect screen DPI, resolution, and pixel aspect ratio by reading from the Capabilities class at runtime.
By using the System class in ActionScript, you can read a number of useful device resources and their consumption at runtime. In this lesson, you'll learn how to monitor CPU and memory usage in a mobile application.
The Android Market keeps its own set of statistics for submitted applications, but if you want customized data reporting, an additional analytics package may be required. In this lesson, you'll see how to use an analytics package - specifically, the Google Analytics service using the GAforFlash ActionScript library - to track certain user views and interactions from within a mobile application.