LITTLEBIGPLAY.COM - FREE ONLINE GAMES   DONAGAMES.COM - GAMES FOR GIRLS     CONTACT ME    
    SHAJBY  MY CREATIONS 
FLASH GAMES | FOR KIDS | ANDROID ONLINE GAMES | TABLET GAMES | ANDROID GAMES | WEBSITES


TUTORIALS

1. How to load SWF with JAVA and package it as APK file!
2. LET'S MAKE SOME MONEY - ADDING LEADBOLT ADS!
3. FINDING PAIRS #1 - FLASH GAME TUTORIAL
4. FINDING PAIRS #2 - PUBLISHING AN ANDROID VERSION WITH ADOBE AIR
5. FINDING PAIRS #3 - ADDING MORE FUNCTIONALITY TO OUR ANDROID GAME
6. EARNING EVEN MORE MONEY WITH REVMOB - ADDING REVMOB TO OUR ANDROID GAME!!

Do you want to see more tutorials? Please buy me some beer! :)





5) FINDING PAIRS #3 - ADDING MORE FUNCTIONALITY TO OUR ANDROID GAME!

This time we will add some more functionality - CLOSING APP, CONTROLLING APP BY DEVICE BUTTONS - to our Android game, that we created in the previous tutorial

REQUIREMENTS
- download a game file
- Adobe Flash CS5 or higher
- basic Flash and AS3 knowledge

1) Open the game file in ADOBE CS5 or higher

2) The game file is almost the same as the file we created in the previous tutorial! We just added a new movieclip inside the library (CTRL+L) called PhoneMenu! This PhoneMenu will appear after we press the MENU button on the phone and it has an EXIT APP button to close the app!

3) Now we must add some code to make it work! The code is already pasted in the game (download), I will just explain here some code for your!

import flash.display.MovieClip;

//we must add event listener to our app, so it recognizes when the app was closed or when the button on your phone was pressed!
if(Capabilities.cpuArchitecture=="ARM"){
NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, deactivateHandler);
NativeApplication.nativeApplication..addEventListener(KeyboardEvent.KEY_DOWN, _onKeyDown);
}

//function closing the appp
function deactivateHandler(event:Event):void{
NativeApplication.nativeApplication.exit();
}

//we pressed the button on phone
function _onKeyDown(event:KeyboardEvent):void{
//if the button was BACK button
if(event.keyCode == Keyboard.BACK){
event.preventDefault(); //dont do anything
//you can add here your own actions that happen after you press the BACK button (main menu, mute etc)
}else if(event.keyCode == Keyboard.MENU){
event.preventDefault(); //dont do anything
showMenu(); //we want to show up our PhoneMenu from the library after we press MENU button
}else if(event.keyCode == Keyboard.SEARCH){
event.preventDefault(); //dont do anything
}
}

var menu:MovieClip;//variable storing our menu that appears after pressing MENU button on the phone

//shows/hides the menu after you press MENU button
function showMenu():void{
if(!menu){//if menu doesnt exist, show it!
menu = new PhoneMenu()
addChild(menu)
menu.btnExit.addEventListener(MouseEvent.MOUSE_UP,exitApp); //add an action to the exit button
}else{ //if menu exists => remove it!
removeMenu();
}
}

//removing the MENU from the stage
function removeMenu():void{
if(menu){
removeChild(menu)
menu = null;
}
}
4) Thats it! We can PUBLISH the APK as shown in the previous tutorial!

After you install it on your phone, you can press the MENU button on your phone and you will see the MENU appear (press EXIT APP to close the game). If you press the MENU button again, the menu will be closed!

Its a good idea to have some more buttons in this PhoneMenu movieclip, for example MUTE, PAUSE, MAIN MENU buttons!

I hope you enjoyed this short tutorial!

Next time I will prepare a tutorial about Tweener, for me the most useful external library to move the objects with!


TUTORIALS

1. How to load SWF with JAVA and package it as APK file!
2. LET'S MAKE SOME MONEY - ADDING LEADBOLT ADS!
3. FINDING PAIRS #1 - FLASH GAME TUTORIAL
4. FINDING PAIRS #2 - PUBLISHING AN ANDROID VERSION WITH ADOBE AIR
5. FINDING PAIRS #3 - ADDING MORE FUNCTIONALITY TO OUR ANDROID GAME
6. EARNING EVEN MORE MONEY WITH REVMOB - ADDING REVMOB TO OUR ANDROID GAME!!

Do you want to see more tutorials? Please buy me some beer! :)





 
 
Copyright © shajby 2010-2011