5 Replies Latest reply on Nov 30, 2011 6:58 AM by Operandom

    Mobile App - Drag and Drop

    wanderingWriter Level 1

      Hello everybody,

       

      I'm working on a mobile flex app for iOS with the 4.5.1 SDK and AIR 2.7.

      So far, everything works quite well.

       

      In my app (a game) I need to drag some pictures around. Now, I know that drag and drop is not supported on list-based controls, but I've coded my own custom component (a simple s:Group with a s:Image inside, plus some business logic in AS) and I've successfully managed to implement the drag and drop operations I needed. Simply put, by dropping the image on the destinations I pass a mere string as part of the DragSource.

       

      Now... This works on the simulator and both on the iPad and iPhone, which is great, but it does only because I have been handling MouseEvents rather than TouchEvents. However, I don't want to work with MouseEvents because I can't find a way to get rid of the mouse cursor during the drag, which appears on the touchscreen beneath my fingertips. Speaking of which... any help on this matter? That would solve the proplem.

       

      Anyway, I do have set this parameter:

      Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

      And I've already made sure that the application reacts to simple taps and touches on the device. However, if I edit my custom component to work with TouchEvents I get stuck with the fact that the DragManager.doDrag() method requires a MouseEvent as argument.

       

       

      I imagine that instantiating a new MouseEvent and then populate it with the TouchEvent's properties they both share won't work.

       

      I tried to use the .startTouchDrag() method defined in the Sprite class: it works great if one wants to move stuff around the stage, but all I need is to drag something ON something else to pass a mere piece of data – a String – and adapting it to my needs is proving cumbersome.


      I figured I should manually handle the whole process, but I also want the dragged item to jump back to the starting position if the drop location is wrong (which is the default behaviour with the MouseEvent-based Drag&Drop), and I’m afraid I’ll end up using too many processing resources and slow the app down. Is there any convenience way out-of-the-box to do what I need?

       

      Thanks a lot.

      Cheers