Posted By

ryanstewart on 02/04/11


Tagged

playbook


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

kuril
rejoydominic
thastyle


Swipe Gestures With QNXApplicationEvents on the BlackBerry PlayBook


 / Published in: ActionScript 3
 

URL: http://www.youtube.com/watch?v=s_dPH7DRLWI

  1. import mx.events.FlexEvent;
  2.  
  3. import qnx.events.QNXApplicationEvent;
  4. import qnx.system.QNXApplication;
  5.  
  6. import views.DetailView;
  7.  
  8. private var startX:Number;
  9. private var startY:Number;
  10. private var endX:Number;
  11. private var endY:Number;
  12.  
  13. protected function mobileapplication1_creationCompleteHandler(event:FlexEvent):void
  14. {
  15. QNXApplication.qnxApplication.addEventListener(QNXApplicationEvent.SWIPE_START,onSwipeStart);
  16. }
  17.  
  18.  
  19. protected function onSwipeStart(event:QNXApplicationEvent):void
  20. {
  21. stage.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDown);
  22. stage.addEventListener(MouseEvent.MOUSE_UP,onMouseUp);
  23. }
  24.  
  25.  
  26. protected function onMouseDown(event:MouseEvent):void
  27. {
  28. startX = event.localX;
  29. trace('mouse down: ' + event.localX);
  30. }
  31.  
  32. protected function onMouseUp(event:MouseEvent):void
  33. {
  34. endX = event.localX;
  35. trace('mouse up: ' + event.localX);
  36. trace('difference: ' + (startX - endX));
  37.  
  38. var diff:Number = startX - endX;
  39. // if it's negative, we're moving right
  40. if(diff>0)
  41. {
  42. trace('popView');
  43. navigator.popView()
  44. } else {
  45. trace('pushView');
  46. navigator.pushView(DetailView);
  47. }
  48.  
  49. stage.removeEventListener(MouseEvent.MOUSE_DOWN,onMouseDown);
  50. stage.removeEventListener(MouseEvent.MOUSE_UP,onMouseUp);
  51.  
  52. }

Report this snippet  

You need to login to post a comment.