Guest User

Untitled

a guest
Jun 24th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. package org.tuio.gestures {
  2.  
  3. import flash.display.DisplayObject;
  4. import flash.geom.Point;
  5. import org.tuio.TuioEvent;
  6. import org.tuio.TouchEvent;
  7.  
  8. public class CustomDragGesture extends OneFingerMoveGesture {
  9.  
  10. public function CustomDragGesture() {
  11. super();
  12. }
  13.  
  14. public override function dispatchGestureEvent(target:DisplayObject, gsg:GestureStepSequence):void {
  15.  
  16. var cursorX:Number = gsg.getTuioContainer("A").x * gsg.getTarget("A").stage.stageWidth;
  17. var cursorY:Number = gsg.getTuioContainer("A").y * gsg.getTarget("A").stage.stageHeight;
  18.  
  19. if (gsg.getValue("offset") == null) {
  20. var tuioPosition = new Point(cursorX, cursorY);
  21. var targetPosition:Point = new Point(gsg.getTarget("A").x, gsg.getTarget("A").y);
  22. gsg.storeValue("offset", tuioPosition.subtract(targetPosition));
  23. }
  24.  
  25. var offsetX:Number = gsg.getValue("offset").x;
  26. var offsetY:Number = gsg.getValue("offset").y;
  27.  
  28. var cursor:Point = new Point(cursorX-offsetX, cursorY-offsetY);
  29.  
  30. var data:Object = {"stageX": cursor.x, "stageY": cursor.y};
  31. gsg.getTarget("A").dispatchEvent(new CustomGestureEvent(CustomGestureEvent.DRAG, data));
  32.  
  33. if (gsg.getValue("lP") != null) {
  34. var velocity:Point = cursor.subtract(gsg.getValue("lP") as Point);
  35. trace("velocity: " + velocity);
  36. }
  37.  
  38. gsg.storeValue("lP", cursor);
  39. }
  40.  
  41. }
  42.  
  43. }
Add Comment
Please, Sign In to add comment