6 Replies Latest reply on Apr 14, 2011 2:02 AM by OZDD

    Not working DragManager on AIR Android

    OZDD

      I developed an AIR Application 2.6 for Android Samsung Galaxy Tab.

       

      If i use the DragManager in a Desktop Application the DragManager is working fine but if i test it on Android

      the DragManager ist not working.

       

      You can test it with a normal Halo Button like:

       

      <mx:Button xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:s="library://ns.adobe.com/flex/spark"
                xmlns:mx="library://ns.adobe.com/flex/mx"
                mouseMove="dragIt(event)">

       

      Here is the Event-Handler dragIt:

       

      private function dragIt(event:MouseEvent):void {
                      var dragInitiator:Button = Button(event.currentTarget);
                     
                      var dragSource:DragSource = new DragSource();
                      dragSource.addData("add_something", "some data");
                     
                      // Create a copy of the image to use as a drag proxy.
                      var img:BitmapAsset = new buttonIcon() as BitmapAsset;
                      var dragImg:Image = new Image();
                      dragImg.source = img;
                     
                      // calculate dragImage offset
                      var offset:Point = new Point(event.localX - img.width / 2, event.localY - img.height / 2);
                     
                      DragManager.doDrag(dragInitiator, dragSource, event, dragImg, offset.x, offset.y);               
                  }

       

      Is there any way to solve the problem or can i wait until the next AIR SDK Release.

        • 1. Re: Not working DragManager on AIR Android
          Flex harUI Adobe Employee

          What error are you getting?

          • 2. Re: Not working DragManager on AIR Android
            OZDD Level 1

            that is exactly the problem. I get no error the DragManager.doDrag is simply not working. If i put everything in a try-catch block nothing appears. So everything seems to work fine but the doDrag method doesn't work.

             

              var dragInitiator:Button = Button(event.currentTarget);

             

            try
            {

                            var dragSource:DragSource = new DragSource();
                            dragSource.addData("add_something", "some data");
                           
                            // Create a copy of the image to use as a drag proxy.
                            var img:BitmapAsset = new buttonIcon() as BitmapAsset;
                            var dragImg:Image = new Image();
                            dragImg.source = img;
                           
                            // calculate dragImage offset
                            var offset:Point = new Point(event.localX - img.width / 2, event.localY - img.height / 2);
                           
                            DragManager.doDrag(dragInitiator, dragSource, event, dragImg, offset.x, offset.y);

            }

            catch(e:Error)
            {
                            this.label += e.errorID + "; " + e.name + "; " + e.message;
            }

            • 3. Re: Not working DragManager on AIR Android
              Flex harUI Adobe Employee

              Normally there is a whole protocol to drag/drop.  It starts with a mouseDown

              then a mouseMove while the mouse is down.  It looks like your code will fire

              on any mouseMove and there is probably code in DragManager that thinks the

              drag is over if the mouseEvent.buttonDown is false.

              • 4. Re: Not working DragManager on AIR Android
                OZDD Level 1

                If i set the dragIt(event) method to mouseDown, mouseMove or both the Desktop Version works fine but not on Android.

                The code is based on flex livedoc example:

                 

                http://livedocs.adobe.com/flex/3/html/help.html?content=dragdrop_7.html

                 

                There is only a handler for mouseMove to initiate the DragManager.doDrag(...).

                In a further example the DragManager is initiated by the mouseDown event.

                 

                http://www.switchonthecode.com/tutorials/simple-flex-drag-and-drop

                 

                It doesn't matter because the DragManager gets the mouseEvent directly (third parameter) and can check

                mouseDown = true internally.

                 

                Every other Mouse or Touch Events are working fine in my application on Android and Desktop.

                • 5. Re: Not working DragManager on AIR Android
                  OZDD Level 1

                  We are also working with a Dell Latitude XT2 Multitouch Notebook and the DragManager works with fingers.

                  • 6. Re: Not working DragManager on AIR Android
                    OZDD Level 1

                    I found the reason for the not working DragManager. It is depending on the operating system.

                    If you use Windows 7 every TouchEvent is converted to a MouseEvent and the DragManager is working properly.

                     

                    But if your Flex Application is running on an Android System not every TouchEvent is converted to an MouseEvent (MouseClicks works for example).

                    It happens that the DragManager.doDrag is not receiving the necessary MouseMove Events from TouchMove because of the missing conversion.

                     

                    One solution would be to cast/convert every TouchEvent into a MouseEvent for the DragManager.

                    The second solution could be the adoption of the DragManager to TouchEvents.