Copy link to clipboard
Copied
I am trying to add Joystick support to a MXML/Flex based application (FlashBuilder, using Apache Flex 4.12.0, FP 13, AIR 13.0beta) but it does not seem to work.
I am adding the following lines in the preinitialize function of the main MXML (which is the earliest point I can call a function I assume):
<s:WindowedApplication
preinitialize="preinitialize(event)"
[...]
/>
<fx:Script>
<![CDATA[
private function preinitialize($event : Event) : void
{
var gameInput : GameInput = new GameInput();
gameInput.addEventListener(GameInputEvent.DEVICE_ADDED, onDeviceAdded);
trace("GameInput.isSupported - " + GameInput.isSupported); // returns true
trace("GameInput.numDevices - " + GameInput.numDevices); // returns 0
}
private function onDeviceAdded($event : GameInputEvent) : void
{
trace("GameInput.isSupported - " + GameInput.isSupported); // returns true
trace("GameInput.numDevices - " + GameInput.numDevices); // returns 0
}
[..]
</fx:Script>
However, the trace for "GameInput.numDevices" always returns "0".
The USB Device is connected properly; when I run the same code in a pure AS project (Flash Professional, same AIR SDK 13) the "GameInput.numDevices" trace returns "1".
This means, the device is working and the MXML/Flex must be the bottleneck.
Does anybody know, if I'm either missing something, or if this is an issue/bug with Flex/MXML?
[Update]
- Unplugging and replugging the device correctly calls the event handler and numDevices is displayed with "1". However, this is no solution, since the identification of the device needs to happen without such an procedure.
- With an older SDK (Flex SDK 4.6 + AIR SDK 3.8) the device is actually correctly identified from the start so there must be a bug in the newer AIR SDK version(s). I will fill out a bug report for this and post it here for reference.
[Update 2]
Bugbase report URL: https://bugbase.adobe.com/index.cfm?event=bug&id=3749005
Message was edited by: janfriedrich