We provide here complete source code and comments for our Android AIR app that you can download and install from the Android Market. Open the Android Market on your phone and search for MazeFM. You can then download and install the app.
The app is a new rendition of the classic maze game. Generate a new perfect maze at a touch of a button. Steer the ball through the maze by moving your finger around a cool and easy to use steering wheel. Choose a level of difficulty you want to play.
Obviously we cannot show the app in action on this page but here are a couple of still screen shots of the phone screen. Click the image or the text link above it to open the full resolution image.
- Download all source files corresponding to this effect: androidmaze.zip
The zip file contains custom AS3 classes: MazeDataGenerator, MazeCell, and MazeDisplay. It also contains the file MazeFM.fla. The classes are used to randomly generate perfect mazes with arbitrary numbers of rows and columns and render them on screen. We used the classes in our earlier tutorial Perfect Maze Puzzle in AS3 Flash, Random Maze Generator. The class MazeDisplay has undergone some changes. It no longer uses the keyboard input. Instead the class provides a public moveBall(..) method. That allows for creating fancy mechanisms for moving the ball through the maze like our steering wheel in this app.
The MazeFM.fla file was created from AIR for Android template that becomes available in your Flash CS5 after you download and install AIR for Android Extension for Flash CS5 from the Adobe site. See our Android example AIR for Android Application KaleidoscopeFM - Source Code for useful links how to get started with AIR for Android in Flash CS5. After you open MazeFM in Flash CS5, you must go to File -> AIR Android Settings and set those all over again; that is, create or enter your p12 certificate under Deployment, choose Deployment type and After Publishing options. With our phone-computer setup, we worked with Device Release, Install application..., and Launch application checked, in Portrait, Full Screen mode. With these settings, each time we clicked Publish under File menu, a new version of the app was automatically installed and launched on the phone hooked up to the computer. In order for this to work, you need to download Android SDK and sometimes a driver for your phone. Again, see the AIR for Android Application KaleidoscopeFM - Source Code example for instructions.
What We Have Learned
Mouse events versus touch events A touch screen understands mouse events with an obvoius event mapping: MouseEvent.CLICK is understood as TouchEvent.TOUCH_TAP etc. Unless you need to catch more then one touch at a time or want to use gesture events, it is is better to use mouse events. With mouse events an app recognizes one touch at a time and doesn't look for more. Thus, less CPU power is used. Even though our steering wheel looks like a gesture event driven gizmo, it is in fact using only mouse events.
What if an app is running in a background The FPS is automatically dropped to 4 FPS. Thus, listening for DEACTIVATE event only to decrease the frame rate when an app is idle, doesn't seem worthwhile.
The MazeFM app was written by Barbara Kaskosz and Dan Gries.