Smooth stage swipe/drag on iPad2
I've come up with a solution using touch events in an attempt to mimic the iOS stage swipe gestures.
Essentially, the solution I've come up with is to use a large MC called 'tiles' with 4 x (1024x768) panels inside it. It works great on my iPad2
The only problem I'm having with it is that when the app launches, it be dragged right (swipe to the right). I would rather drag it left as that feels more comfortable to me.
If anyone could help with this, I'd really appreciate it, otherwise, I think this is a really neat solution and I've provided the AS3 below.
Mike
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
tiles.addEventListener(TouchEvent.TOUCH_BEGIN, homeTouchBegin);
tiles.addEventListener(TouchEvent.TOUCH_END, homeTouchEnd);
var homeDragBounds:Rectangle = new Rectangle(0, 0, 3072, stage.stageHeight-768);
function homeTouchBegin(event:TouchEvent):void {
event.target.startTouchDrag(event.touchPointID, false, homeDragBounds);
}
function homeTouchEnd(event:TouchEvent):void {
event.target.stopTouchDrag(event.touchPointID);
if (tiles.x < 512) {
TweenLite.to(tiles, .5, {x:0, ease:Strong.easeOut});
}
else if (tiles.x > 512 && tiles.x < 1024){
TweenLite.to(tiles, .5, {x:1024, ease:Strong.easeOut});
}
else if (tiles.x > 1024 && tiles.x < 1536) {
TweenLite.to(tiles, .5, {x:1024, ease:Strong.easeOut});
}
else if (tiles.x > 1536 && tiles.x < 2048) {
TweenLite.to(tiles, .5, {x:2048, ease:Strong.easeOut});
}
else if (tiles.x > 2048 && tiles.x < 2560) {
TweenLite.to(tiles, .5, {x:2048, ease:Strong.easeOut});
}
else if (tiles.x > 2560 && tiles.x < 3072) {
TweenLite.to(tiles, .5, {x:3072, ease:Strong.easeOut});
}
else {
TweenLite.to(tiles, .5, {x:3072, ease:Strong.easeOut});
}
}
