Android AIR Development

You will need the FlexSDK (4.5.1), AndroidSDK (android-tools), JDK (5), and the latest AIR SDK (2.7.1) to get these examples running on your phone. I believe you might also need the latest .net runtime to get Flashdevelop to work.

I wanted to try out something in flash and decided to give Flashdevelop 4 Beta 3 a go. I got seriously side tracked from the goal that I was intending to achieve. I saw that they made it easy to publish air applications to the android device. I instantly wondered if I could do my idea on my phone and if the Flixel framework would work on the phone. As you might know, I had a look into the Flixel library for AS3 recently and was very much impressed.

Flixel Flod

Seeing as I recently acquired a fair amount of new .mod files… I wondered if I could get @photonstorm‘s flxel power tools flod implementation to work on my phone. Maybe a bit ambitious for a first project. It required no converting of code or anything. It was pure and simple. I got this result after a few minutes and here is the source. On my phone it is considerably slower in debug mode, however it seems to run fine when compiled for release. Here is the source.


Next I wanted to know what features I could get a hold of on my phone. The following projects have source included, but it are very rough. They do however show the concept very crudely in each case. I acquired most of the source from Jonathan Campos blog. First up we have the camera activities that can be done, I should have gotten a model for this section.

Here is an example of displaying the output from the camera to the application and the source. For some reason it appears tilted on my phone. Nothing a rotation can’t fix. The CameraUI allows you to take a photo and the information about the picture is sent back to the application including location. The CameraRoll brings up the native picture selection and sends back similar information, to the CameraUI program, of the selected picture. Both do not work on the PC environment.


Here is an example of using the Accelerometer and the source. Seeing as my laptop does not have an accelerometer, the example does not work. But on my phone the ball moves around when you tilt the phone. Only the velocity of the ball is effected.





Here is an example of how to use the communication channels of the phone and the source. This was the simplest of them all, you use the standard navigateToUrl call that you use in flash. The only difference is you pre-pend what protocol you want, eg. tel:777-7777 or sms:777-7777. Each button will take you to the respective native interfaces of the device. The buttons are from the Flixel library.



I tried the geolocation next and was not too impressed. You have to get a signal and once you have that you can start guessing the location. The sample rate also has to be low to save battery power. Here is the example program, but I was not patient enough to see it working on my phone.


The microphone can also be accessed from flash, much in the same way you do normally. The blue bar will grow the noisier it is. It does not work on the PC environment, but does on my phone. I am running the GalaxyS and the speaker is really sensitive. In the screenshot I included what the example project structure looks like.

Phone Buttons

You can stop the default behaviour of two of your buttons (of the three) on the phone by assigning listeners to the buttons. Here is the project, you will have to manually exit this example from your phones task manager. Nothing much to look at, but texts gets added when you press the buttons at the bottom of the phone.




Screen Orientation

Determining screen orientation does not function as well as what I would have liked it to. This example needs some serious improvement to show the concept, but it works for a very basic one. You could code you own implementation polling the accelerometer yourself. However, I am not sure what the benefit would be.


Lastly, I know that the GalaxyS can have 5 touch points which it can register. Not that I have seen an application that makes use of it yet. (Yes there are some, but I do not download tons of apps and test them). I got the example from… sigh, lost the link. However, I had to make some changes to get it running. The performance of this degrades very fast, but the concept can be seen. Quite funky! Once again, my laptop could not demonstrate what the application actually does… it draws lines between your presses. Here is the source.

And this ended my one evening of play with AIR and Android with Flashdevelop 4 Beta. It was great fun! My assumption is that any Actionscript 3 code will work, which means all of the funky libraries we are used to. Flash is waaaayyyyy more fun than Java!