Skip to main content
Participant
January 21, 2013
Question

AIR for Android - actionscript 3, back button

  • January 21, 2013
  • 1 reply
  • 2163 views

I am creating an app for Android using the AIR for Android option in Adobe Flash, I have chosen to make the mobile app swipe, so all that code works, however, on every page except the home page I want to add a back button to go back to the home page. But because all  pages are in one movie clip.. I do not know how to make the button because everything is in the first frame? There isn't an option in code snippets and I can't find it the code online either. Please help

This topic has been closed for replies.

1 reply

sinious
Legend
January 21, 2013

It comes through as a flash.ui.Keyboard event called "BACK".

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/ui/Keyboard.html#BACK

You want to listen for the event and then stopPropatation() as well as preventDefault() on the event so you can handle it yourself.

Participant
January 22, 2013

I don't understand what you mean? Is there no code I can edit? So far for the swipe gesture, the code I am using is:

/* Swipe to Go to Next/Previous Frame and Stop

Swiping the stage moves the playhead to the next/previous frame and stops the movie.

*/

Multitouch.inputMode = MultitouchInputMode.GESTURE;

var currentGalleryItem:Number = 1;

var totalGalleryItems:Number = 16;

stage.addEventListener (TransformGestureEvent.GESTURE_SWIPE, fl_SwipeToGoToNextPreviousFrame);

function fl_SwipeToGoToNextPreviousFrame(event:TransformGestureEvent):void

{

          if(event.offsetX == 1)

          {

                    if(currentGalleryItem > 1){

                              currentGalleryItem--;

                              slideRight();

                    }

          }

          else if(event.offsetX == -1)

          {

                    if(currentGalleryItem < totalGalleryItems){

                              currentGalleryItem++;

                              slideLeft();

                    }

          }

}

var slideCounter:Number = 0;

function slideLeft(){

          gallery_items.addEventListener("enterFrame", moveGalleryLeft);

}

function slideRight(){

          gallery_items.addEventListener("enterFrame", moveGalleryRight);

}

function moveGalleryLeft(evt:Event){

          gallery_items.x -= 48;

          slideCounter++;

          if(slideCounter == 10){

                    gallery_items.removeEventListener("enterFrame", moveGalleryLeft);

                    slideCounter = 0;

          }

}

function moveGalleryRight(evt:Event){

          gallery_items.x += 48;

          slideCounter++;

          if(slideCounter == 10){

                    gallery_items.removeEventListener("enterFrame", moveGalleryRight);

                    slideCounter = 0;

          }

}

Participant
January 22, 2013

and this code works on the Android phone ...