How to make a game for Android using Air and FlashDevelop... Action Games Adventure Games Arcade Games Defense Games Dressup Games Search... http://www.lorenzgames.com/blog/how-to-make-a-game-for-... Driving Games Fighting Games Multiplayer Games Puzzle Games Rhythm Games Register Forgot Password? Shooting Games Sport Games War Games Webcam Games 3D Games Username •••••••• Login Home Blog Upload ToolBar Bookmark Contact Download Free Games - Become a Fan on Facebook! W WAARR O OFF T THHEE W WOORRLLDDSS W WEEBBCCAAM M PPLLAAYYSS:: 1 16 63 38 80 08 8 W WEEBBCCAAM M LORENZGAMES, ALL ABOUT FLASH GAMES! Games RSS | Blog RSS SEARCH Search... CATEGORIES How to make a game for Android using Air and FlashDevelop M MAAYY 1 15 5TTHH,, 2 20 01 11 1 -- C CAATTEEGGOORRYY:: ActionScript3, Android, FlashDevelop, Flex Making games for Android is very easy thanks to Air and FlashDevelop. It is actually also free, if you manage to make your art assets without using Flash IDE. Before to start make sure you download and install all the necessary: - Java JRE Make sure you have JAVA on your machine. Sometimes it happens that even if you have it, the class path is not registered, so make sure that the command ‘java’ is available. (You can test it from the cmd by writing: java, if you get an error then you already have a problem.) 3D ActionScript 3 ActionScript3 Advertising Android Design Developers Flash FlashDevelop Flex Games General Math MochiAds Monetize Multiplayer PHP Publishers Sounds RECENT ARTICLES - Flex SDK Extract it into your C:, for example i put mine into C:/flex How to create an Isometric tile and get all the dimensions - Air SDK Extract it in the same directory where you have the Flex SDK. (Overwrite few files) Away3D 3.6 Cookbook Amazing! - Android SDK Extract it into C:, mine is at C:/android-sdk - FlashDevelop ...of course you need FlashDevelop. - Custom Android + Air Template for FlashDevelop This template has to be extracted into the projects folder of FlashDevelop, ( …mine is C: /Program Files (x86)/ FlashDevelop /Projects ) READY, SET, GO! To keep this tutorial short I decided to create a fairly easy game, Tic Tac Toe, I created the art assets using Flash CS4, here you can download the SWC file. How to make a game for Android using Air and FlashDevelop BitmapData: draw VS copyPixels Away3D 3.6 Essentials Waiting for Away3D 3.6 Essential TAGS 3D ActionScript 3 Advertising As3 Away3d Book Developers Flash Flex Games General Image Monetize Multiplayer Nonoba PHP Publishers Rotation Sounds Sponsorship 1 of 7 09/10/2011 18:45 How to make a game for Android using Air and FlashDevelop... http://www.lorenzgames.com/blog/how-to-make-a-game-for-... Open FlashDevelop and start a new project, you will see something like this: Then go Menu - Project - Properties... and set the Dimensions to 800 x 1200. This game is only going to have the portrait mode, also you will notice that 1200, instead of 1280, this is because in the Honeycomb the little bar on the bottom steals 80 pixels. 2 of 7 09/10/2011 18:45 How to make a game for Android using Air and FlashDevelop... http://www.lorenzgames.com/blog/how-to-make-a-game-for-... Also don’t forget in the Compiler Options to add your custom path to Flex. Now edit your Main.as, it will look pretty much like this: package { import import import import import import flash.display.MovieClip; flash.display.Sprite; flash.display.StageAlign; flash.display.StageScaleMode; flash.events.MouseEvent; flash.events.Event; import import import import import flash.system.Capabilities; flash.desktop.NativeApplication; flash.desktop.SystemIdleMode; flash.events.KeyboardEvent; flash.ui.Keyboard; /** * Tic Tac Toe for Android via Air * @author Lorenzo Nuvoletta * @link http://www.lorenzgames.com/blog */ public class Main extends Sprite { private var turnType:int = 2; private var playScreen: PlayScreen; private var aEB:Array = [1, 1, 1, 1, 1, 1, 1, 1, 1]; private var stopPlay:Boolean; public function Main():void { stage.align = StageAlign.TOP; stage.scaleMode = StageScaleMode.SHOW_ALL 3 of 7 09/10/2011 18:45 How to make a game for Android using Air and FlashDevelop... http://www.lorenzgames.com/blog/how-to-make-a-game-for-... playScreen = new PlayScreen(); playScreen.winner.visible = false; addChild(playScreen); playScreen.addEventListener(MouseEvent.CLICK, click //Check if being run on Android device if(Capabilities.cpuArchitecture=="ARM") { NativeApplication.nativeApplication.addEventListener NativeApplication.nativeApplication.addEventListener NativeApplication.nativeApplication.addEventListener } } private function click(e:MouseEvent):void { var mc:MovieClip = e.target as MovieClip; var c:String = mc.name; var ac:Array = c.split("_"); if (!stopPlay && ac[0] == 'boardElement' && mc.currentFrame mc.gotoAndStop(turnType); aEB[ac[1]] = turnType; turnType = turnType == 2 ? 3 : 2; var winner:int = checkWinner(); if (winner != 1) { stopPlay = true; playScreen.winner.visible = true; playScreen.winner.winnerElement.gotoAndStop } } else if(c== 'resetButton'){ for (var i:int = 0; i < 9; i++) { playScreen.board['boardElement_' + i aEB[i] = 1; stopPlay = false; playScreen.winner.visible = false; } } } // Winner checker private function checkWinner():int { if (aEB[0]!= 1 && aEB[0] == aEB[1] && aEB[ else if (aEB[3]!= 1 && aEB[3] == aEB[4] && aEB[3] == else if (aEB[4]!= 1 && aEB[6] == aEB[7] && aEB[6] == else if (aEB[0]!= 1 && aEB[0] == aEB[3] && aEB[0] == else if (aEB[1]!= 1 && aEB[1] == aEB[4] && aEB[1] == else if (aEB[2]!= 1 && aEB[2] == aEB[5] && aEB[2] == else if (aEB[6]!= 1 && aEB[6] == aEB[4] && aEB[6] == else if (aEB[0]!= 1 && aEB[0] == aEB[4] && aEB[0] == else return 1; } aEB aEB aEB aEB aEB aEB aEB private function handleActivate(event:Event):void { NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode } private function handleDeactivate(event:Event):void { NativeApplication.nativeApplication.exit(); } private function handleKeys(event:KeyboardEvent):void { if(event.keyCode == Keyboard.BACK) NativeApplication } } } Set the autoOrients to false into the application.xml, Doing so you will make sure that the game always remain in portrait mode. Also for now you don’t need those strings written in the 'manifest' so if you want you can delete them. In the 'bin' folder you will be able to find 3 icons (36, 48, 72), feel free to change them using your own art, but keep the correct sizes. You are almost there, make sure that CreateCertificate.bat and 4 of 7 09/10/2011 18:45 How to make a game for Android using Air and FlashDevelop... http://www.lorenzgames.com/blog/how-to-make-a-game-for-... PackageApplication.bat have the correct path to the SDKs then execute CreateCertificate.bat first and then PackageApplication.bat, the default password is ‘fd’. (The file InstallRuntime.bat is only used if you are testing with virtual devices and you need to install Air runtime all the times) Now a file named “AndroidProject.apk” has been generated into the folder “bin_android”, load that on your Android device and install it (before you do it remember to allow Unknown sources in Settings-Applications). And that’s pretty much it, enjoy your new custom made game. Download here the entire source code. Sharing is caring... A RRTTIICCLLEE C OOM MM MEEN NT TSS A ALLBBEERRTT - M MAAYY 1 17 7TTHH,, 2 20 01 11 1 Dude that's COOL.... I will try it ASAP. Thanks! How do you upload it though to the android Market? Thanks! A ANNDDRREEAASS - M MAAYY 1 18 8TTHH,, 2 20 01 11 1 Hey! First of all, great guide. I'm having a problem with PackageApplication.bat though. When I reach the part where a password is requires, it doesn't allow any input from me - i.e. I cant write anything. Did I mess up something real bad, or do I just have to wait a little longer before I can put in the password? A ANNDDRREEAASS - M MAAYY 1 18 8TTHH,, 2 20 01 11 1 Hello again. I solved my problem. Turns out, there's no visual feedback when typing in the password. Might be worth mentioning. Once again, thank you for the great guide, and a briliant source-code. U UB B-M MAAYY 2 29 9TTHH,, 2 20 01 11 1 hi, i try the PackageApplication.bat n get this error "Initial window content SWF 11 version exceeds namespace version" how to fix this error? JJOONN - A AUUGGUUSSTT 1 1SSTT,, 2 20 01 11 1 Hi, thanks for the tutorial! I am having trouble installing the swc file, however. I've never used one before, so I am trying to place it in the profile folder, then right click and 'Add to library' as this is what I think I have to do based on some googling, but FlashD then becomes unresponsive and my CPU goes into overdrive. Is it doing something intensive here? Should I leave it until it's done? How long should it take? Am I even doing this right? Any help would be much appreciated, thank you. LLOORREENNZZ - A AUUGGUUSSTT 1 1SSTT,, 2 20 01 11 1 What kind of issue are you having with the SWC? JJOONN - A AUUGGUUSSTT 2 2NNDD,, 2 20 01 11 1 Ok I just tried it all again on my work PC, and this time the swc was added with no problem. My issue with the swc at home is that I would right-click the swc and select "Add to library", but then FlashD would seem to hang whilst using all my CPU (the fan whirs up to full). I left it like this for 20 minutes in case it was busy doing something, but on my work PC it worked instantly. Though I do have an issue using packageapplication.bat on my pc due to a namespace error: C:FlashTicTacToe_Androidapplication.xml: error 305: Intial window content SWF version 11 exceeds namespace version http://ns.adobe.com/air/application/2.5 LLOORREENNZZ - A AUUGGUUSSTT 3 3RRDD,, 2 20 01 11 1 Yep, 20 minutes wait to load a SWC is certanly not the case your settings. 5 of 7 there must be something wrong with 09/10/2011 18:45 How to make a game for Android using Air and FlashDevelop... http://www.lorenzgames.com/blog/how-to-make-a-game-for-... JJAACCKK B BRROOCCKKLLEEYY - A AUUGGUUSSTT 2 28 8TTHH,, 2 20 01 11 1 Thank you, this worked perfectly. Now it's time to have fun and make an Android game with FlashDevelop! Woooo. - SSEEPPTTEEM MBBEERR 5 5TTHH,, 2 20 01 11 1 Your essay is good, I like it very much. Here I would like to share with you some things Replica Handbags: http://www.replicabagsell.com ---shacai C CH HA AU USSSSU URREESS FFEEM MM MEESS SSTTUU - SSEEPPTTEEM MBBEERR 6 6TTHH,, 2 20 01 11 1 Nice tutorial. Needs updating though... By which I mean just use a fresh install of FlashDevelop 4 Beta. It includes the SDKs and "one-button" packaging to an .apk file, and has a nicer new Android project setup. FFRREEEEZZEEEEEE -O OCCTTOOBBEERR 3 3RRDD,, 2 20 01 11 1 thank's bro, its very useful -O OCCTTOOBBEERR 6 6TTHH,, 2 20 01 11 1 Thanks it is working. How can i choose flash player 6 ? The options i have starts from 9. BBA ABBIISS W WRRIITTEE AA C COOM MM MEEN NTT:: N NAAM MEE ((R REEQQUUIIRREEDD)):: 1 1 PPLLUUSS 1 1 ?? ((RREEQQUUIIRREEDD)):: EE--M MAAIILL:: W WEEBBSSIITTEE:: Submit Affiliate Link: Free Games | DressUp Arcade | Z-Fox | Flash Games | Free Games | Girls Games | Free Online Games | Cute Girly Games | Car Games | Dress Up Games | Melting Mindz | Play Free Games Welcome to LorenzGames.Com. The Funniest and Most Addicting Free Flash Online Games in 3D and 2D such as arcade games, action games, puzzle games, sport games, multyplayer games and more. The Best place to play online games for free! LorenzGames! - Free, Funny and Addicting OnLine Games. Highscores | Custom Levels | Blog | Contact Us | Submit a Game | Download Our Free Toolbar | Links | Download Free Games for your WebSite | Privacy Policy | Thumbnail Generator | Sitemap Third-party trademarks are used solely for distributing the games indexed herein and no license or other affiliation is implied. Copyright 2008-2009 LorenzGames.Com. All rights reserved Lorenzo Nuvoletta. 6 of 7 09/10/2011 18:45 How to make a game for Android using Air and FlashDevelop... 7 of 7 http://www.lorenzgames.com/blog/how-to-make-a-game-for-... 09/10/2011 18:45