Testing AIR for Android with Flash Develop using ADB over Wifi

This is very cool when you have faulty/old USB ports on your computer (like me, making it so frustrating to test my apps on the device).

First configure your device to enable ADB over wifi, these instructions from StackOverflow worked for me (root), I’ll just paste them here:

Manual Process

From your device, if it is rooted

According to a post on xda-developers, you can enable ADB over Wi-Fi from the device with the commands:

setprop service.adb.tcp.port 5555
stop adbd
start adbd

And you can disable it and return ADB to listening on USB with

setprop service.adb.tcp.port -1
stop adbd
start adbd

From a computer, if you have USB access already (no root required)
It is even easier to switch to using Wi-Fi, if you already have USB. From a command line on the computer that has the device connected via USB, issue the commands

adb tcpip 5555
adb connect

Be sure to replace with the IP address that is actually assigned to your device.

You can find the IP address of a tablet in two ways:

Manual IP Discovery:

Go into Android’s WiFi settings, click the menu button in the action bar (the vertical ellipsis), hit Advanced and see the IP address at the bottom of the screen.

Use ADB to discover IP:

Execute the following command via adb:

adb shell ip -f inet addr show wlan0

To tell the ADB daemon return to listening over USB

adb usb

Apps to automate the process

There are also several apps on Google Play that automate this process. A quick search suggests adbWireless, WiFi ADB and ADB WiFi. All of these require root access, but adbWireless requires fewer permissions.

source: http://stackoverflow.com/questions/2604727/how-can-i-connect-to-android-with-adb-over-tcp

Now in your FlashDevelop files, remove the -d param from adb install calls.

In RunApp.bat and PackageApp.bat, change :

adb -d install -r "%OUTPUT%"


adb install -r "%OUTPUT%"

In SetupApp.bat set the IP of your computer, this way you won’t have to type it when your app launches for debug in your device

:: Debugging using a custom IP

Now when you run your project…



Can’t believe it took me days to figure this out, I was very close, but I didn’t know I had to remove the -d param that directs the command to the only connected USB device.



My device was still showing when the List Of Devices Attached displayed (adb devices command) but appeared as offline instead of “device”.

What worked for me was

adb disconnect

and then:

adb connect


OpenFL error parsing package

I was testing OpenFL Android target (and by the way the JDK that worked for me was jdk1.6), but when I tried to install the app on my phone the “error parsing package” message showed up and didn’t let me continue.

Turns out the project.xml was wroooong:


The cool thing is that the the first thing they tell you is to name “package” correctly.

So I applied the fix:


And all was great.

Life hack: don’t be like me.



[Snippet] Get array of (non-repeated) random Numbers.

I’ll save my story because of bleh.

Given a range, get N numbers (within that range) without repeating one.


Numbers wanted: 3.

From range : 8 – 23.

Result: 10, 19, 8.

private function getRandomNumbers(low:Number, high:Number, howMany:Number):Array
var store:Array = [];

if (howMany > high)
trace(“too many numbers wanted, howMany must be less or equal to high”);
return store;

while (store.length < howMany)
var randNum:Number = Math.floor(Math.random() * (1 + high – low)) + low;

if (store.indexOf(randNum) == -1)


return store;

Isn’t non-formatted code a thing of beauty?


var min:Number = 5;
var max:Number = 20;
var howMany:Number = 6;

var rNums:Array = getRandomNumbers(min, max, howMany);

Kinda lame alghoritm, I’m not very good at math and logic (and somehow I am a programmer), but there it is.

Update (1 day later): thanks to @sophistifunk for pointing me to use indexOf, so I saved some lines 🙂


[Catch] Using Admob Ane Android error

So I followed the instructions to use Admob Ane within my Starling/Feathers game:


But got an error:


Or some stuff like that, that didn’t break the game, but the ad was not showing.

Turns out, I didn’t have Google Play Services in my Android SDK so I installed it (along other stuff, just in case).


Yeah I’m not a hardcore dev so I didn’t have it installed sue me (please don’t sue me).

And just like that, after doing so, I could see my game with ad$$$


ez moneeyyyyyy


In case you’re having problems trying to compile with any ANE, checkout Philippe’s (easy) solution:




BluetoothSender (or yet another Native Process post)

Bluetooth communication in Flash is not possible natively (yet), so using Java (with Bluecove library) you can achieve this by using Native Process in AIR.

It works like this: FlashApp < — > AIRApp< — > Java. Of course, the AIRApp needs to be working on the background, and the FlashApp will be you main application (or it can be another AIR application).

I created an API to let Flash send commands to bluetooth, by the way it uses AS3 Signals for events dispatching. This is a code sample for searching devices:

If the image looks a bit blurry, then you need glasses, nah just kidding, it actually looks like that

“Yeah that’s cool, but how do I set everything up to create my app?” ok here it goes:

The first thing you need to do is to install BluecoveAIR

When you run it for the first time, select the path to javaw.exe by clicking the “Hey! Select Javaw.exe” button, the location is stored (via SharedObject) so you don’t have to set that again.

A window will aid you to navigate to choose the exe file.

Once it’s done you can see the “hello, Java stared” text (and a blue light indicator) that confirms that Java is good and ready to go.

That’s pretty everything you need to do in order to start using API. You can notice some options for Local Connection, these are default settings, if you wanna change them, type the new connection names in the input fields, but also remember to change them in the FlashBluetooth constructor in your Flash app.

constructor params

Local Connection default settings in the constructor (you may want to click the image).

This is a demo application to show how it works. You don’t have to worry much about the java output, it just displays what’s going on.

Note: First, place an mp3 file called “myFile” on drive C:\

Let’s start by doing a device inquiry, for that click “Search devices”. When finished, copy an address and paste it in the input text.  Then press the Download button.

When transfering the file, you’ll receive some permission notifications in your device, just accept them. Also will ask you to type PIN or code, it is 0000 (four zeros). The PIN code is hardcoded in the Java app, but yes, I will add the option to change that.

Download: AS3 API (with a few docs), sample app, BluecoveAIR and Java executables and source codes here

This was tested on Windows XP, Vista and 7, 32 bit. When I tried it on a Win7 x64 it didn’t work, so beware. (On that x64 machine, I later removed  Win7 64 and then installed a 32 bit Win XP and it went ok)

It breaks my heart not being able to generate a .dmg since I don’t have a Mac =P but if someone creates it, let me know. Also if you wanna clean and/or optimize the Java source code.. please do.

Here’s a video showing it in action

(sorry for my bad english :X lol, not that “bad english”, I mean my pronunciation)

Flash CS5 on Linux! (using Wine)

I recently started moving to Linux as my main O.S., I’m using Mint 10 (Julia) and I’ve been liking it so far. Of course there are obvious difficulties when making the transition, since how to change the mouse pointer to how to install a program, but once you get familiarized with that stuff you feel like home.

As a developer I want my tools working on my new shiny Linux, there are great ActionStript code editors that work on it, Realaxy, FDT, IntelliJ and some other that are AIR based (which are free). I chose IntelliJ, and coming from FlashDevelop it’s a bit hard to make the transition, but not impossible. Ok so I got a good code editor, but one of the most important things I need to do is to export swc files from Flash (animated Movie Clips, custom buttons and stuff). As you may know, there’s no Linux support for the CS products, so you need to do some funny stuff.

“Yeah yeah, just tell me how to run Flash CS5 on Linux”.

It’s very simple proccess which is decribed here http://int3ractive.blogspot.com/2010/08/how-to-run-flash-cs5-on-ubuntu-with.html a very cool blog by @trongthanh (quality tweets!). In another post he also explains how to use Flash Builder on Ubuntu in case you are interested.


Here’s how CS5 look running on Mint, quite fine.


Yeah a glitchy thing but it's ok to meh

Yes maybe there are some tiny glitches that make your content look cropped, but it’s still intact


I tested exporting a swc from there, and then imported it into IntelliJ and worked as expected 🙂

AIR 2 Native Process with Java

Hi! Today I’m going to show you how to “mix” Java and ActionScript (I would call it JavaScri—umm no) with the help of the awesome Native Process class.
What exactly does this example app do?
It “magically” (tired of hearing that word actually) types text into a TextInput, yes types, I mean not setting the TextInput.text property, it’s done using the Java Robot class. When you click the “Hello” radio button, that word is typed, the same happens with the “Bye” radio button.

The app looks like this

The Java code is very simple, it just writes a text simulating key presses using the Robot class, if the java program receives as a parameter “Hello” it will type “Hello” in an Textfield of our application, also outoputs a string that will be read by the AIR app, making possible a two-way communnication (sorry for not having syntax highlight and formating):

public void checkForInput()


BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

String text = “”;



text = in.readLine();

if (text.equals(“Hello”))




Robot robot = new Robot();







}//robot try

catch (AWTException e)



}// robot catch

}//if = hello

if (text.equals(“Bye”))




Robot robot = new Robot();




}//robot try

catch (AWTException e)



}// robot catch


}// try in.readLine

catch(IOException e)


System.err.println(“Exception while reading the input. ” + e);

}// in.readLine Catch



String stringToConvert = “Lolz from Java”;

byte[] theByteArray = stringToConvert.getBytes();    

DataOutputStream dataOutputStream = new DataOutputStream(System.out);




catch(IOException e)

{     System.err.println(“Exception while reading the input. ” + e);



Now the Flexy part:

First lets set the JRE location in our machine, in this example the URL is hardcoded, and may vary depending on your OS or your JRE installation settings, you can also make the app to open a window and let you browse to the location.

(All the following is executed when the “Start Java” button is clicked)

var file:File = new File(“C:\\Program Files\\Java\\jre6”);
file = file.resolvePath(“bin/javaw.exe”);

Next we need to set te arguments in a Vector, with this, we tell JRE to execute our JAR file

var arg:Vector.<String> = new Vector.<String>;

Now we create an instance of NativeProcessStartupinfo, this will contain our arguments vector and the location of the javaw.exe

var npInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
npInfo.executable = file;
npInfo.arguments = arg;

We have our parameters ready, now lets create a native process and start it with the npinfo that contains the necesary data to run our jar, and an event listener to receive data from Java.

nativeProcess = new NativeProcess();

nativeProcess.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onStandardOutputData);


There we go!, but don’t get excited this won’t do anything LOL so lets send some parameters:

(This code is executed when one of the radio buttons is clicked)

nativeProcess.standardInput.writeMultiByte(e.currentTarget.label+”\n”, “utf-8”);

Note: The “\n” is necessary since The in.readLine() in java considers a line when a text ends with “\n”

And w00t! That sent the parameter to Java and the text is automatically written.

Okay, but what do we do if we want to read data sent from java? easy, inside the onStandardOutputData function write:


And you will be able to see a message in the console everytime you click a radio button.

I’ve added the source (both FB and Java) files here

And here are some other post and articles related to Native Process: