A tester for testing controllers with AIR!
Now running at a smooth 60 frames per second!
This is still 100% a work in progress.
This tutortial assumes you already have an AIR application setup in FlashDevelop with the proper batch files. If you don't, simply create a new project as an AS3 AIR Projector and go from there.
extension/folder into the root directory of the AIR FlashDevelop project
libfolder in FlashDevelop, and right click on
adl "%APP_XML%" "%APP_DIR%", add
-extdir extension/debug/at the end
adl "call adt -package %OPTIONS% %SIGNING_OPTIONS% -target native %AIR_TARGET% %APP_XML% %FILE_OR_DI, add
-extdir extension/release/at the end
set AIR_TARGET=change it to
set AIR_TARGET=air/ProgramName.exe, where ProgramName is the name of your game!
Inputclass or wherever really
Joystick, it should look something like
private var joystick:Joystick = new Joystick();
joystick.JoyQuery()at the beginning of every update. This checks for any controller changes or button presses
Joystickobject. An example would be
joystick.buttonIsDown(0, 0), checking to see if Button 1 (Index 0) is being pressed on Controller 1 (Index 0)
PackageApp.batand select "Execute" (or just double-click if you're in Windows Explorer). This should created your exe in the
air/directory. You should be good to go! Install it, try it, and enjoy it. :)
The rest is up to you! For the analog controls, I'd suggest setting thresholds or making your movement based upon the analog value of the stick. If you are having trouble figuring out the values for a controller, use AIR-Controller-Tester.
Class path: (import extension.JoyQuery.Joystick;)
public function Joystick()
Creates a new Joystick instance.
public function JoyQuery():void
Query the joysticks to update their possitions for the other functions. Best to call this on an ENTER_FRAME event.
public function getTotal():Number
Returns the total number of connected joysticks.
public function buttonIsDown(joystickNum:Number, buttonNum:Number):Boolean
Returns true if the selected joystick number and button number is down, false if it is up.
public function getAxis(joystickNum:Number, axisNum:Number):Number
Returns the position selected joystick number and axis number. Ranges from -1 to 1.
public function getTotalButtons(joystickNum:Number):Number
Returns the total number of buttons on the selected joystick.
public function getTotalAxes(joystickNum:Number):Number
Returns the total number of axes on the selected joystick.
AIR Controller Tester is exactly what it sounds like, an AIR application that is used to get the input values of different buttons and axes of Joysticks. This is useful for figuring out input thresholds and what buttons you need to be checking for.
This currently only support Windows. I'd love to get a Mac (and Linux) version working soon.
AIR Controller Tester uses JoyQuery 2.0 as an extension to support native controller input.
My name is Brett Chalupa, and I want to play all my favorite Flash games with controllers. If you want to integrate this into your game, send me an email. I am working on creating a video and text tutorial for getting it working with FlashDevelop 4.0, Flixel/FlashPunk. If I am too slow for you, just let me know and I can give you all the secrets early.