-
Swipe/Drag/Pan an Object such as a list?
Ok, so I'm starting to delve into developing for touch enabled devices.
However, in looking over the AS3 Multitouch API documentation, I'm having a hard time seeing how to I can differentiate between different gestures or touches.
Take the example of a list, which is commonly seen on almost every mobile app.
If you "swipe" the list, it would animate/roll for awhile and then ease to a stopping point.
However, you can also "drag" the list, so that the list would simply move along with the touch point, so you could move a finer distance, like 1 or 2 items at a time.
You might be able to even "pan" the list (two fingers), which would move the list one page at a time.
Adobe has already gone to the trouble to "synthesize" the idea of a "swipe" which is considered a GestureEvent. However, there is no "drag" event, per se. From what I can tell, a "drag" is made up of several touch events... TOUCH_BEGIN, TOUCH_MOVE, TOUCH_END. Which, seem pretty similar to the mouse events that would accomplish the same result.
So, I guess my question is how do I logically tell the difference between a "swipe" and a "drag"? I basically don't know how to write the if/else conditional to test which event I actually want to react to, because they both can trigger? Is a "swipe" just a "drag" with velocity?
Take the code below, I doubt what I want can be accomplished by a single if/else statement, but this ultimately is what I want to do:
Actionscript Code:
if(swipe) { // what goes here?
// Tween the list based on speed of swipe / length of swipe (I know how to do this, sort of.)
}else if(drag){ // what goes here? // Move the list along with finger until user stops touching the screen (I know how to do this). }
I know all the syntax for adding listeners and what-not, so I don't really need anyone to write the code for me (yet). But, I guess I do need to know how to logically construct the conditionals... or maybe I need to listen for the "swipe" event only after the user has touched the list, etc.?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|