Introducing Airxbc 0.5

UPDATE December 30, 2012
This post is out of date. For information on the latest version of Airxbc, see this page.

Lately I've been working on a new native extension that makes it possible to control your Adobe AIR games using the Xbox 360 controller. I'm currently calling it Airxbc (Air Xbox controller - ha HA!) and this 0.5 release is pretty much just an alpha test to get something out there. It think its pretty cool and plan on putting more work into it in the relatively near future. If you're interested, check out the video and details below!

Airxbc is Windows only as it relies on the XInput library from Microsoft. This library ships with most recent versions of the Windows OS and is part of the DirectX SDK so there's a good chance you already have it.

How it works

To use Airxbc in your projects, you just need to download the ane file at the end of this article and add it to your AIR project. I developed the sample application using FlashDevelop and have included the project files below so you can download it and see how it all works. Note that projects using native extensions cannot be packaged as standard .air installers. Instead they must be compiled to a native executable (.exe on Windows).

Please see this page for more information about setting up native extensions in FlashDevelop.

The current release, 0.5, has support for all the buttons on the 360 controller except the big orb button in the middle. The extension's pollGamePad method returns all the data in a generic ActionScript object. This is something I intend to change in the near future, but for now, that's how it works. The object contains the following properties:

error - 0 if no errors are present
A - if not 0, the A button is being pressed
B - if not 0, the B button is being pressed
X - if not 0, the X button is being pressed
Y - if not 0, the Y button is being pressed
leftShoulder - if not 0, the left shoulder button is being pressed
rightShoulder - if not 0, the right shoulder button is being pressed
back - if not 0, the back button is being pressed
start - if not 0, the start button is being pressed
dpadUp - if not 0, the dpad's up button is being pressed
dpadDown - if not 0, the dpad's down button is being pressed
dpadRight - if not 0, the dpad's right button is being pressed
dpadLeft - if not 0, the dpad's left button is being pressed
leftTrigger - a value between 0 and 255 (255 = fully depressed, 0 = not pressed)
rightTrigger - a value between 0 and 255 (255 = fully depressed, 0 = not pressed)
leftStickX - a value between -32768 and 32768 (-32768 = all the way left)
leftStickY - a value between -32768 and 32768 (-32768 = all the way down)
rightStickX - a value between -32768 and 32768 (-32768 = all the way left)
rightStickY - a value between -32768 and 32768 (-32768 = all the way down)

How to use

To use the extension simply create a new instance of it and call the methods as needed. The callable methods are pollGamePad, setVibration and dispose. Here's a quick example:

import com.rhuno.Airxbc;

var ext:Airxbc;
ext = new Airxbc();

var object:Object = ext.pollGamePad();

   ext.setVibration(20000, 20000);

function onExit():void

We covered the pollGamePad method earlier, but the setVibration and dispose methods are new. You call setVibration to utilize the 360 controller's rumble feature. The function takes in two arguments: the speed for the left motor and the speed for the right motor. These arguments should be a number between 0 and 65535 with 0 stopping the motors. The dispose method should be called when the extension is no longer needed.

Building an executable

As mentioned earlier, you can't build a normal .air file when using native extensions. If you want to build an exe from Flashdevelop you'll need to modify the Packager.bat file located in the bat directory. First, at the end of the set OUTPUT line, change .air to .exe. Then on the line where it says call adt, in between %SIGNING_OPTIONS% and %OUTPUT% add this: -target native. At the end of that same line add: -extdir extension/release/. It should look similar to this once complete:

call adt -package %OPTIONS% %SIGNING_OPTIONS% -target native %OUTPUT% %APP_XML% %FILE_OR_DIR% -extdir extension/release/

Thanks for checking this out. Below you'll find links to download the ane file and also the example project if you want to play with it yourself.

Airxbc example project

Bookmark and Share

7 Responses to “Introducing Airxbc 0.5”

  1. Ben says:

    Announced by Adobe, made by you :)
    Looks realy handy for Air based games

  2. Saravans says:


    Really a cool stuff…

  3. gonzos says:

    Is this work only with xbox 360 controller or we can use any of controllers?

  4. joe says:

    this is pretty cool :) shame i sold my xbox before moving home.. but definitely a step forward for gaming everywhere. keep it up!

  5. Rhuno says:


    I haven’t tried it with any other controllers, but I’m fairly certain it will only work with the Xbox 360 controller.

  6. LeoSpider says:


    if i have 2 or more xinput devices, how can i select a device? or it only reads 1st device?

  7. Rhuno says:

    When you call the pollGamePad method you can pass in the index (zero based) of the device you want to get data for. You can check out the details here:

Leave a Reply

Subscribe to RSS feed FGS5 Badge