Copy link to clipboard
Copied
Hi,
I seem to have a conflict between two gesture events I'm trying to use - Swipe and Zoom.
I have a movie clip on frame one of the main timeline which has 4 items and it swipes perfectly left and right.
That works fine until I try to add a zoom function to an image of frame 25 of the same/main timeline.
If I test the movie, I can swipe the first movie no problem. Then if I navigate to frame 25 I can pinch/zoom on the image on that framed.
But when I navigate back to the swipe gallery it doesn't work.
I'm using the code snippets but these two functions don't seem to like working together in the same file.
Can someone please tell me what I'm doing wrong.
Thanks
============== Here's what I'm using for the Swipe function on frame 1 ==================================
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;
}
}
============== Here's what I'm using for the pinch/zoom function on frame 25 ==================================
Multitouch.inputMode = MultitouchInputMode.GESTURE;
stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM, fl_ZoomHandler_2);
function fl_ZoomHandler_2(event:TransformGestureEvent):void
{
movieClip_1.scaleX *= event.scaleX;
movieClip_1.scaleY *= event.scaleY;
}
stop();
Copy link to clipboard
Copied
I thought I had the solution when I realised I was adding the event listener for the zoom to the stage rather thant to the image/movie clip I want to be able to zoom in on.
I had this:
stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM, fl_ZoomHandler_2);
So I changed it to this:
bike_mc.addEventListener(TransformGestureEvent.GESTURE_ZOOM, fl_ZoomHandler_7);
I did this because it works on the swipe gesture that's been working fine:
gallery_items.addEventListener (TransformGestureEvent.GESTURE_SWIPE, fl_SwipeToGoToNextPreviousFrame);
What's happening is that the swipe function works, then when I go to the frame with the zoom image on it that works too. But then when I go back to the swipe frame it doesn't work.
But now I've changed the event listener to the movie clip rather than the stage I'm getting this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at TUESDAY_fla::MainTimeline/frame25()[TUESDAY_fla.MainTimeline::frame25:14]
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at flash.display::MovieClip/gotoAndStop()
at TUESDAY_fla::MainTimeline/fl_ClickToGoToAndStopAtFrame_8()[TUESDAY_fla.MainTimeline::frame1:145]
Puzzled!!?
Copy link to clipboard
Copied
Even tried removing the event listener for the zoom function when returning to the swipe gallery frame:
stage.removeEventListener (TransformGestureEvent.GESTURE_ZOOM, fl_ZoomHandler);