Developing a Deployment Strategy, Considering Connectivity

0
161

If you create an application to deploy on Android, iOS, and the desktop, use different compilation processes. In Flash Professional, create different Flash files and document classes.

In Flash Builder, create separate projects. Define the project dimension in the initial Window tag of the descriptor file. If you are only developing for the Android platform, your Main class should handle the device’s capabilities and instructions on layout, as described earlier.

Considering Connectivity

Unlike with the desktop experience, you cannot assume your user is always connected when using a mobile device. She might be moving in and out of networks. Be prepared to display a message if your application is not able to function because of this.

At startup and during the life of your application, you can check the state of connectivity. AIR on the desktop has this functionality, but it is not part of the package for AIR for Android. Rest assured: the classes you need are available.
Go to the AIR SDK and navigate to Frameworks→Projects→AIR→Core→src→AIR→Net. Copy all four air.net classes into the src directory on Flash Builder and next to your document class in Flash Professional. Change the package name from package air.net to just package.

You can check the status on URLMonitor for an HTTP request or on SocketMonitor for a socket connection request. Both classes extend from the ServiceMonitor class.

Here is an example of an HTTP request:

import URLMonitor;
import SocketMonitor;
import flash.net.URLRequest;
import flash.events.StatusEvent;

var monitor:URLMonitor =
new URLMonitor(new URLRequest(“http://www.google.com”));

monitor.pollInterval = 1000;
monitor.addEventListener(StatusEvent.STATUS, onStatus);
monitor.start();

function onStatus(event:StatusEvent):void {
monitor.stop();
trace(event.code); // Service.available or Service.unavailable
trace(event.target.available); // true or false