Do code snippets conflict with each other?
Hi,
I'm trying to use two code snippets in the same app I'm working on.
The code snippets are swipe and zoom. So I've got an image gallery which swipes perfectly. Then on another frame I've got an image that I want to pinch and zoom in on.
If I go to either of those first they both work fine. The problem occurs when I go to one after the other.
So if I go to the image I want to zoom in on first that works fine. But when I go to the frame with the gallery I want to swipe left and right on afterwards, it stops working.
And it happens vice versa: if I go to the swipe gallery first, it works fine. But when I go to the zoom image, that stops working.
Here's the code I'm using:
For the zoom image:
Multitouch.inputMode = MultitouchInputMode.GESTURE;
stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM, fl_ZoomHandler1);
function fl_ZoomHandler1(event:TransformGestureEvent):void
{
bike_mc.scaleX *= event.scaleX;
bike_mc.scaleY *= event.scaleY;
}
For the swipe gallery:
Multitouch.inputMode = MultitouchInputMode.GESTURE;
var currentGalleryItem:Number = 1;
var totalGalleryItems:Number = 4;
gallery_items.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;
}
}
"
Thanks for any ideas in advance.
