Copy link to clipboard
Copied
I have two different elements that need a swipe gesture on the same scene.
I'e been working with
Multitouch.inputMode = MultitouchInputMode.GESTURE;
square1.addEventListener(TransformGestureEvent.GESTURE_SWIPE, onSwipe);
function onSwipe(e: TransformGestureEvent): void {
if (e.offsetX == 1) {
//User swiped towards right
square1.x += 100;
}
if (e.offsetX == -1) {
//User swiped towards left
square1.x -= 100;
}
if (e.offsetY == 1) {
//User swiped towards bottom
square1.y += 100;
}
if (e.offsetY == -1) {
//User swiped towards top
square1.y -= 100;
}
}
square2.addEventListener(TransformGestureEvent.GESTURE_SWIPE, onSwipe2);
function onSwipe2(e: TransformGestureEvent): void {
if (e.offsetX == 1) {
//User swiped towards right
square2.x += 100;
}
if (e.offsetX == -1) {
//User swiped towards left
square2.x -= 100;
}
if (e.offsetY == 1) {
//User swiped towards bottom
square2.y += 100;
}
if (e.offsetY == -1) {
//User swiped towards top
square2.y -= 100;
}
}
square1 and square2 being my 2 elements.
I can swipe one and then the other one won't work. What could i do so the gesture doesn't get stuck on just one of the events?
try testing on a mobile device instead of the emulator.
Copy link to clipboard
Copied
there's no problem with your code. there could be a problem with those two objects and their positions relative to each other.
Copy link to clipboard
Copied
these are my two elements, they arent close to each other, i can swipe wherever i want on the screen and it would only affect the first one i interacted with
Copy link to clipboard
Copied
try testing on a mobile device instead of the emulator.
Copy link to clipboard
Copied
You are right! Thank you very much, i was desperate!
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now