29 May 2014
Modern day technology presents several unique uses for today’s advanced smart phones. Adobe’s AIR 15.0 offers a restructured 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 AIR 15.0 Beta and download the AIR SDK. The SWC file is located at AIR SDK\frameworks\libs\gamepad.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:
AIRGamepadobject using the
getGamepad(gamepadID:String)static method of the
connect(stage:Stage, publisher:String,applicationURL:String)function of the
connect()function from the Flash Player application, the user is prompted for a PIN.
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 from AIR SDK\runtimes\air\android\device\Runtime.apk, 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.
drawImage(encodedImage:ByteArray) of the
AIRGamepad class 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 AIR 15.0 Beta and download the AIR SDK. The SWC file is located at AIR SDK\frameworks\libs\gamepad.swc.
You can only use images in the JPEG format for the Gamepad skin. The
DRAW_ERROR 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(duration:int) function of the
AIRGamepad class is used to vibrate the device. You can also fetch gesture and touch events and take suitable action.