FlashDevelop & Adobe AIR... I can breathe!

Eclipse + Java are not really my style, so I figured I'd try Adobe AIR.

Adobe AIR works out-of-the-box -mostly-.

FlashDevelop works out-of-the-box -moderately-

The meat:

Since there are keyboard binding for the game pad it seems the D-PAD, analogue sticks and the O and U buttons are mapped to common keyboard keys. You can access them with a standard stage.addEventListener(KeyboardEvent.KEY_DOWN, callback); call.

I will be writing proper game pad hooks in the days to come, but for now you CAN port your games made in AS3. This would include Flixel, FlashPunk, Stage3D, PaperVision, etc. It also means you can program in HAXE or AS3. I know there are a lot of HAXE fans out there.

The potatoes:
For now, I'll provide a real OUYA Adobe Air example and how to work with it.

First download the example for comparison purposes http://danmckinnon.net/downloads/mobile_air_test.zip

This is mostly a normal Flash Develop Mobile Air 3 template, so I'll walk you through how to make this project on your own.

1. Create the project
image

2. Edit 'Run.bat' and change
SCREEN_SIZE=1080

3. Now go to Project->Properties
4. Change the platform to Air 3.1

5. Open application.xml and change the application name space to AIR 3.1 on line 2
<application xmlns="http://ns.adobe.com/air/application/3.1">;

6. In the folder /bat, run the program CreateCertificate.bat once
7. In the root folder, now run /PackageApp.bat
Choose option 3, captive package. This just includes the AIR Runtime with the program so the OUYA doesn't have to download it seperately.

UBUNTU
8-1. Install android development tools. In Ubuntu, this can be done with the command
sudo apt-get install android-tools-adb

WINDOWS
8-2a. In windows you will have to download the Android SDK from here http://developer.android.com/sdk/index.html
8-2b. In Windows set your PATH environment variable to point to the bin directory. To do that I think you go to Control Panel->System->Environment then edit the PATH variable, add a semi-colon followed by c:\android-sdk\bin. This will give you command-line access to ADB so you can install software onto your OUYA from your PC. It should look something like this
PATH=c:\windows\system;c:\windows;c:\windows\system32;c:\android-sdk\bin

9. In a console window, change directory to /dist
10. Assuming you have only the OUYA connected and no Virtual Devices or other androids type...
adb install -r MobileAirTest-captive-runtime.apk

11. On the OUYA go to Devs->Software
12. Your project should appear as an Adobe AIR icon.
13. Viola! Run it and enjoy a breath of fresh AIR.

Note:
For the bulk of your work, test on the PC and deploy on the OUYA sparingly. It's a bit of a bulky way to do the bulk of your testing andthis way you won't get any debugging features when running on the OUYA.

I'm sure there is a way, so once I figure out a quicker way to run a debugging environment on the OUYA I will post instructions.

Suese
TheSuese.com - Elite Developer Backer

Comments

  • mfrasiermfrasier Posts: 10Member
    Thanks for this, will check it out!
  • SueseSuese Posts: 120Member
    Key-Bindings Reference:

    O = 13 KEY_ENTER
    Left = 37 KEY_LEFT
    Up = 38 KEY_UP
    Right = 39 KEY_RIGHT
    Down = 40 KEY_DOWN


    The other buttons don't work, and the A key even exits the program. A little bit buggy but it's a tremendous start.
    TheSuese.com - Elite Developer Backer
  • mfrasiermfrasier Posts: 10Member
    Seuse, it's possible A is mapped to BACK which by default would exit. It's possible that you can trap the keyboard back event and prevent default on it.
  • nobleRobotnobleRobot Posts: 118Member
    edited January 2013
    That's no bug. The "A" button is mapped to the Android BACK key (unless it is assigned to something else using the ODK, which is unavailable to AIR without a native extension).

    Likewise, the "U" button is assigned by default to the Android MENU key (I don't have a dev kit, I'm just going by the docs).

    The only face button that doesn't have a default Android key binding is the "Y" button.
    Post edited by nobleRobot on
  • SueseSuese Posts: 120Member
    I'm looking into Native Extensions for Android. I'm going to attempt some proper ODK hooks tomorrow after I finish porting Shorty 2600 to OUYA tonight.

    If someone is familiar with Native Extensions for Android, I'm curious about using STDOUT to communicate events..

    I worry that using STDOUT to communicate to the AIR application might have some latency, which is no good if it's going to have to make a lot of constant calls to the ODK anywhere.
    TheSuese.com - Elite Developer Backer
  • mfrasiermfrasier Posts: 10Member
    edited January 2013
    OK, for folks building in Adobe Flash Professional (I'm using CS6), I created a new Android project with the runtime set to AIR 3.5 for Android. FLA dimensions were 1920x1080, landscape and the runtime was included of course.

    I built a simple app that would record key strokes and then trace out the keyCode. Here is what I got:

    up 38
    down 40
    left 37
    right 39
    left click 13
    right click 13
    O 13
    U 16777234
    A 16777238

    I believe Y might be linked to android menu. I had to do e.preventDefault() to get A from backing out of the app. Clicking in both sticks or pressing O will give you keycode 13 (ENTER). None of the 4 trigger buttons returned any codes.

    The directional codes are thrown for the left control stick and D-Pad only. Right stick only gives me ENTER (13) on click -- no directional.
    Post edited by mfrasier on
  • SueseSuese Posts: 120Member
    I ported a game over and I'm finding AIR is running excruciatingly slow and there is major delay in the input. It's not the game, it's something wrong with Android/OUYA/AIR. Anyone have an ideas on how to improve the performance of AIR?
    TheSuese.com - Elite Developer Backer
  • mfrasiermfrasier Posts: 10Member
    Did you try targeting GPU?
  • SueseSuese Posts: 120Member
    :p just trying that now... and.... there is no discernible difference. I added -use-gpu=true to extra compiler options. Benchmark stats are still slow as jerks.
    TheSuese.com - Elite Developer Backer
  • SueseSuese Posts: 120Member
    edited January 2013
    really, the game is simple enough it shouldn't even need GPU rendering though..
    image
    Post edited by Suese on
    TheSuese.com - Elite Developer Backer
  • Volcanic-PenguinVolcanic-Penguin Posts: 90Member
    Wow, nice to see some progress here!
  • rocketbunnyrocketbunny Posts: 46Member
    Make sure you are not running it in interpreted mode. You must build AOT to get proper speed. FlashDevelop by default runs in interpreted mode if you just press F5. You might also want to look into using Starling and Direct mode to use OUYA's GPU. Apologies if you are already doing all of this...
    Robert Crane
    CEO, Rocket Bunny Games
  • SueseSuese Posts: 120Member
    @rocketbunny Thanks. Already there.

    So... bummer.. Stage3D isn't working either.
    TheSuese.com - Elite Developer Backer
  • SueseSuese Posts: 120Member
    AHA!!
    FlashDevelop caveat discovered
    I went into the Project->AIR App Properties->Initial Window->Non Window Platform->Render Mode->GPU

    I thought the compiler flag -use-gpu=true would work, but apparently it did not. My game runs like a CHARM.

    w0000000000000t
    TheSuese.com - Elite Developer Backer
  • SueseSuese Posts: 120Member
    Still can't get Stage3D to work quite yet... I'll let everyone know when and if I do.
    TheSuese.com - Elite Developer Backer
  • rocketbunnyrocketbunny Posts: 46Member
    Glad that you are running fast again. Direct mode is faster than "GPU" mode as long as you use something like Starling to drive it. You might not need to go to that level but it is something to think about.
    Robert Crane
    CEO, Rocket Bunny Games
  • Volcanic-PenguinVolcanic-Penguin Posts: 90Member
    Nice!
  • SueseSuese Posts: 120Member
    edited January 2013
    Post edited by Suese on
    TheSuese.com - Elite Developer Backer
  • SueseSuese Posts: 120Member
    I think my Stage 3D problem is just a matter of updating Flex SDK and Air SDK to Version 3.5
    As this guy mentions: http://chrischurn.co.uk/blog/flashdevelop-stage3d-and-mobile-air3-2/
    TheSuese.com - Elite Developer Backer
  • SueseSuese Posts: 120Member
    OOOUUUYYEAAAH!
    Just download a fresh version of Air SDK 3.5 and copy it directly into your flex-sdk folder. Stage3D enabled and running oh-so-smooth!

    http://www.adobe.com/devnet/air/air-sdk-download.html
    TheSuese.com - Elite Developer Backer
  • Jack_McslayJack_Mcslay Posts: 100Member
    Anyone on the ouya staff listening? We could well use a wiki for this kind of information
  • xMCNUGGETxxMCNUGGETx Posts: 12Member
    I'd also look at Haxe NME. It can produce native android apps and can be coded in FLashDevelop. http://www.nme.io/
  • PuzzlPuzzl Posts: 98Member
    I'd back up that : Haxe+NME. We would need some ways to deploy directly from Haxe/Nme to OUYA tho...Would really fancy that - We'll get into it. Guys, remember, unless you go the Stage3d route, you'll have a hard time keeping up everything at 1920*1080 @60fps. Resolution matters, especially with Flash/Air. But then even so, the swf is just embeded in the apk. Easy for anyone to get the .swf in it (rename .apk to .zip, unzip, find .swf, decompile) and modify/redistribute it. You wouldnt want your work thrown away in seconds, wouldn't you? Hence the Haxe native compiled route - at least no .swf in the deployed .apk, and with native code, no more code overhead, and drawTiles method = full opengl es power. Same code, ten times more power at the very least + protection of apk. Now, if only the analog in NME were properly implemented...
  • WolfosWolfos Posts: 5Member
    My Android SDK (latest version, just pulled from Google's site) has no bin folder. Where do I link to?
  • Killa_MaakiKilla_Maaki Posts: 504Member
    edited April 2013
    Guys, any progress on things like Gamepad and IAP?

    I'm looking into using Away3D 4.1, AwayPhysics, Stage3D, and AIR for developing OUYA games, but I'd love to know if I can get REAL access to the gamepad (all buttons, direct access to stick values, triggers, etc), and I'd also like to be able to trigger IAP calls of course.
    Post edited by Killa_Maaki on
    You didn't remember the plot of the Doctor Who movie because there was none; Just a bunch of plot holes strung together.
  • GaslightGamesGaslightGames Posts: 156Member
    Guys, any progress on things like Gamepad and IAP?

    I'm looking into using Away3D 4.1, AwayPhysics, Stage3D, and AIR for developing OUYA games, but I'd love to know if I can get REAL access to the gamepad (all buttons, direct access to stick values, triggers, etc), and I'd also like to be able to trigger IAP calls of course.
    Full controller and IAP support can be found in the Native Extensions:

    Supports the latest ODK (1.0.3), Home Button, encrypted purchases and receipts... the whole shebang :-)
  • GaslightGamesGaslightGames Posts: 156Member
    I'd also like to say that I've been using Alternativa3D, along with their physics implementation and get ~35fps @ 1080p with full physics steps.
    Take physics out and it's a 60fps jaunt in 1080p :-)

    But if, like me, you want collision detection, rigid body physics etc, it's worth the impact on performance to have those things available to you!
Sign In or Register to comment.