Skip to content

Instantly share code, notes, and snippets.

@noonat noonat/
Created Jun 15, 2011

What would you like to do?
AIR 2.7 Android Example Makefile
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<application xmlns="">
<!-- To localize the description, use the following format for the description element.
<text xml:lang="en">English App description goes here</text>
<text xml:lang="fr">French App description goes here</text>
<text xml:lang="ja">Japanese App description goes here</text>
<!-- To localize the name, use the following format for the name element.
<text xml:lang="en">English App name goes here</text>
<text xml:lang="fr">French App name goes here</text>
<text xml:lang="ja">Japanese App name goes here</text>
<manifestAdditions><![CDATA[<manifest><uses-permission android:name="android.permission.INTERNET"/></manifest>]]></manifestAdditions>
package {
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.utils.getTimer;
public class Game extends Sprite {
private var _ballX:Number;
private var _ballY:Number;
private var _ballVelX:Number;
private var _ballVelY:Number;
private var _ballRadius:Number;
private var _elapsed:Number;
private var _time:Number;
private var _width:Number;
private var _height:Number;
function Game() {
if (stage) {
} else {
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
private function onAddedToStage(event:Event=null):void {
addEventListener(Event.ENTER_FRAME, onEnterFrame);
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
stage.addEventListener(Event.RESIZE, onResize);
stage.align = StageAlign.TOP_LEFT;
stage.frameRate = 30;
stage.scaleMode = StageScaleMode.NO_SCALE;
_width = stage.stageWidth;
_height = stage.stageHeight;
_ballX = Math.random() * _height;
_ballY = Math.random() * _width;
_ballVelX = _ballVelY = Math.min(_width, _height) / 2;
_ballRadius = 16;
_time = getTimer() / 1000;
private function onEnterFrame(event:Event=null):void {
var time:Number = getTimer() / 1000;
_elapsed = time - _time;
_time = time;
_ballX += _ballVelX * _elapsed;
_ballY += _ballVelY * _elapsed;
if (_ballX - _ballRadius < 0) {
_ballX = _ballRadius;
_ballVelX *= -1;
} else if (_ballX + _ballRadius > _width) {
_ballX = _width - _ballRadius;
_ballVelX *= -1;
if (_ballY - _ballRadius < 0) {
_ballY = _ballRadius;
_ballVelY *= -1;
} else if (_ballY + _ballRadius > _height) {
_ballY = _height - _ballRadius;
_ballVelY *= -1;
graphics.drawRect(0, 0, _width, _height);
graphics.drawCircle(_ballX, _ballY, _ballRadius);
private function onResize(event:Event):void {
_width = stage.stageWidth;
_height = stage.stageHeight;
# This is an example Makefile for building Android apps using AIR 2.7. You
# need to have the SDK installed and added to your path.
# To install the AIR 2.7 runtime on your device, run:
# make install-runtime
# To run the game on the device, just run "make".
default: launch
amxmlc -sp+=. -output game.swf
game.apk: game.swf game-app.xml certificate.p12
adt -package -target apk -storetype pkcs12 -keystore certificate.p12 game.apk game-app.xml game.swf
ifeq ($(PASSWORD),)
@echo "\nYou need to create a password. Run:\n\n\tmake certificate.p12 PASSWORD=yourpassword\n" && false
adt -certificate -validityPeriod 25 -cn SelfSigned 1024-RSA certificate.p12 $(PASSWORD)
rm -f game.apk game.swf
debug: game.swf
adl game-app.xml
launch: install
adt -launchApp -platform android -appid game
install: game.apk
-$(MAKE) uninstall # uninstall errors can be ignored
adt -installApp -platform android -package ./game.apk
-$(MAKE) uninstall-runtime # uninstall errors can be ignored
adt -installRuntime -platform android
adt -uninstallApp -platform android -appid game
adt -uninstallRuntime -platform android
.PHONY: clean debug install install-runtime uninstall uninstall-runtime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.