29 May 2014
Modern day technology presents several unique uses for today’s advanced smart phones. Adobe’s AIR 14.0 introduces the AIR Gamepad API that extends the use of Android devices as game controllers and second-screen interfaces. You can use the AIR Gamepad API to connect Flash-based browser applications to a paired Android device running the AIR runtime application.
With the AIR Gamepad API you can:
To download the SWC file go to Wand.swc.
See the API documentation for a detailed description of the API and its applications.
To begin setting up a connection between the game application and the android device, call the
Wand.connect() function. On calling the
Wand.connect() function from the Flash Player application, the user is prompted for a PIN. The PIN is the alphanumeric string displayed on the AIR Gamepad screen on the Android device. The PIN is required to establish a connection with the Android device running the AIR runtime application. See Figure 1.
In order to complete the connection from the game application to the Android device the user needs to:
1. Install the Adobe AIR runtime application on the Android device, if not already installed.
2. Launch the Adobe AIR runtime application.
3. Shake the device. The AIR Gamepad screen is displayed in the AIR runtime application, with a PIN. See Figure 2.
4. Enter the PIN in browser pop-up and click Connect.
Note: Both the Android device and the desktop computer need to be on the same internet network to be able to connect through the AIR Gamepad APIs.
Wand.applyskin(encodedImage:ByteArray) as soon as the connection between the game application and the android device has been established. This will ensure that that the skin is displayed immediately on the Android device’s application screen and the user can begin to control the Flash-based browser game from the Android device. See Figure 3 for an example of the skin displayed for the Flash-based game, HungryHero.
To download the swc file go to Wand.swc.
You can only use images in the JPEG format for the Gamepad skin. The
applySkinError error occurs when any format other than JPEG is used.
Note: Only the rotated-left landscape orientation is supported for Gamepad on Android devices, which is also applicable to the skin.
When a connection between the game application and the android device is successfully established and the skin is applied, the user can begin to use the Android device as a game controller.
HungryHero is an example of a Flash-based game that uses the Gamepad API. Accelerometer events are fetched from the Android device to decide the movements of HungryHero. The Android device vibrates when HungryHero collides with objects or eats food. The
vibrate() function of the Wand class is used to vibrate the device. You can also fetch gesture and touch events and take suitable action.