Search code examples
iosactionscript-3flashactionscriptflash-cs6

Swipe Gesture for iOS in Flash CS6


I'm creating an app for iOS (mainly) in Flash CS6 and I'm having a few problems with getting a particular page to work.

The layout is as follows: I have a movie clip that is 3 times the width of the stage with my content, with the instance name of txtContent.

On a separate layer, my Action Script (v3.0) reads as follows:

import com.greensock.*;
import flash.events.MouseEvent;

//Swipe
Multitouch.inputMode = MultitouchInputMode.GESTURE;

var currentTile:Number = 1;
var totalTiles:Number = 3;

txtContent.addEventListener(TransformGestureEvent.GESTURE_SWIPE , onSwipe); 

function moveLeft():void{
    txtContent.x += 640;
}

function moveRight():void{
    txtContent.x -= 640;
}

function onSwipe (e:TransformGestureEvent):void{
    if (e.offsetX == 1) { 
        if(currentTile > 1){ 
            moveLeft()
            currentTile--
        } else {}
    }

    if (e.offsetX == -1) { 
        if(currentTile < totalTiles){
            moveRight()
            currentTile++
        }
    }
}

stop();

When I test the movie, with a touch layer, the movie clip successfully moves left and right for each swipe, and does not continue to move too far in either direction, in effect ignoring any other swipes.

However, when I compile the IPA and test on the iPhone, only the first two "tiles" move (I can only see two thirds of the movie clip with swiping), as if I swipe to the third "tile" I cannot swipe back at all. No matter what I do, it gets stuck on that third section.

Is there a problem in my code that isn't registering properly in iOS?

FYI, I'm testing on an iPhone 3GS.


Solution

  • It was my own mistake - the final 'page' of the slides did not have a large background with the alpha set to 0% like the others, therefore to slide it back it would only work when holding the text (which was small). With the addition of the background, the movieclip is solid and therefore swiping the whole screen worked fine.