Archive for November, 2010

Open-source Flex “Hero” app: SurveyApe

If you’re interested in creating a complex Android application using Flex, you may have questions about more advanced topics. I wrote a fully featured mobile application called SurveyApe using Flex “Hero,” and I’ve recently released the code, which you can use to answer these questions. You may find the code useful to learn about the Model View Controller architecture, asynchronous Database Access Object design patterns, how to code Flex to handle orientation changes, and a clean way to prevent memory leaks in asynchronous function calls. You can also modify the application as you see fit (but be sure to look at the open source license first).

Here’s a video showing SurveyApe:

You can get the SurveyApe APK and code from Adobe Labs: Flex Dev. Center:

If you’re new to Flash Builder and Flex mobile development, you may want to check out my Flex “Hero” and Flash Builder “Burrito” workflow guide. It’ll help you get started with writing, deploying, and debugging applications on Android devices.

I frequently post about mobile development on Twitter: @antiChipotle.

Code, Package, and Debug Flex mobile apps with Flash Builder “Burrito”

Two weeks ago, Adobe released a preview version of Flash Builder. Codenamed Flash Builder “Burrito,” it’s available on Adobe Labs as a 60-day trial. This version contains many features and enhancements that let you easily deploy applications to Android phones and tablets. You can use the included version of the Flex SDK to create Flex apps for phones like the Droid 2, Droid X, HTC Evo, etc., or code in pure ActionScript 3, and have total control over the Flash app that you choose to deploy. Using Flash Builder “Burrito,” you can code, package APKs, install your applications over USB, and perform on-device debugging using WiFi.

To get users started with Flash Builder “Burrito,” I wrote a 25-page document that was handed out at the Adobe MAX Device Lab. I’m making it available here as a PDF. It serves as a tutorial and reference to walk you through the creation, deployment, and debugging of Flex mobile applications, and has resources for more advanced topics. This workflow guide includes:

  • Creating a new Mobile Project
  • Importing an Existing Mobile Project
  • Adding Code
  • Building
  • Running and Debugging on the Desktop and on a Device
  • Your First Flex “Hero” App: “Hello, World!”
  • Packaging for Release
  • Installing the Android SDK
  • Appendix:
  • Conditional Compilation
  • Managing SDKs
  • Additional Resources

This document can get you started creating multiscreen Flex and AS3 applications, and will show you how to use Flash Builder “Burrito” to deploy and debug your apps on Android devices.

Download it here: Flash Builder and Flex Workflows for Multiscreen App Development [PDF]
Adobe Flash Builder “Burrito” is available as a 60-day free trial here.

Learn to use SQLite in real-world Flex mobile apps

Last week, Adobe announced the public betas of Flex “Hero” and Flash Builder “Burrito.” You can use these tools to begin creating your own mobile applications that run Flash, AIR, and Flex content, and I recommend you check them out here and here. If you’re looking for the next step in getting started with a real-world Flex app, however, you may be interested in the following:

I created an open-source application called SurveyApe, which should help you get started in the process of creating robust, real-world Flex mobile applications. It’s available on Adobe Labs:
Update: New URL: 05/16/2011

SurveyApe utilizes SQLite, the database framework that’s available in Adobe AIR. If you’re new to web or application development, SQLite is a relational database that allows you to store and access large amounts of data using fast, structured queries. If your mobile applications collect medium to large amounts of user data, or if they pull data sets from the Internet, chances are you’re going to want to store in in a database. The use-cases where you want to use a relational database over your own binary file format are numerous. You’ll find databases useful for games, data-driven applications, Twitter and Facebook-style applications that pull down status information, etc. You can use the design patterns I’ve created in SurveyApe to help create these sorts of applications in Flex “Hero” and AIR for Android.

Ostensibly, SurveyApe conducts a survey consisting of a predetermined set of questions, allowing multiple users to use your mobile device and answer the questions that are provided in a sample database. The survey-giver can then review statistics and summary information about the responses, including question breakdowns and some simple demographic data. It’s really useful, however, to demonstrate how to create your own asynchronous database access objects, and the code includes some best-practices for preventing memory leaks and ensuring sane access patterns.

When you first import SurveyApe into Flash Builder (or your IDE of choice), you should open the src/database/ file. This code contains all the SQL that the program can execute, as well as access methods that are accessible from every instance of the Database class (you’ll only want one instance per database). You’ll see the asynchronous pattern I recommend using when you view the various methods in this class.

For example:

 * Gets the list of surveys
 * @param args Expects element 0 to be a DatabaseResponder.
public function getSurveys(args:Array):void
	if ( args[0] is DatabaseResponder )
		var sqlWrapper:SQLWrapper = this.sqlStatementFactory.newInstance(args[0], GET_SURVEYS);


The sqlStatementFactory is an instance of SQLStatementFactory…a class I created to ensure that I have one function responsible for generating event handlers, and–in so doing–I can be assured that every call to the database results in event handlers that are garbage collected. (If you have event handlers registered on an object and you set the object to null, the event handlers will remain in memory, creating a leak.)

Note that I’m passing parameters via weak typing in an Array. This was fast and easy to set up, but you may want to create your own DatabaseArgs Object, which will allow you to access arguments using key value pairs, which is a more robust, safer way to pass arguments.

SurveyApe is too large to cover everything in one blog post, so stay tuned to learn about some more Flex “Hero” and AIR features I utilize…including how to take images and video using using the native CameraUI.

Download survey ape 0.4
Update: Download Survey Ape 0.4