0 Replies Latest reply on Aug 2, 2009 3:41 PM by theodorelizard

    Dropping image on canvas causes image to jump.

    theodorelizard

      When I drop an image on a canvas in AIR the image "jumps" a few pixels to several from the current mouse location.

      So if the mouse is at location (12, 12) and I drop the image it may appear at (10, 14), or (15, 20), or whatever. It doesn't appear to be a consistent offset like I would expect if this were caused by using global to local mouse position thing (but I'm not ruling that out anyway).

       

      Secondly, when I then drag to move the image on the canvas the drag proxy will again jump many pixels from the mouse cursor.

       

      Here is my mouse down handler:

       

                  private function dragBegin(event:MouseEvent):void

                  {

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

       

                      var ds:DragSource = new DragSource();

                      ds.addData(dragInitiator, "img");   

       

                      var dragProxy:Image = new Image();

                      dragProxy.source = event.currentTarget.source;

       

       

                      DragManager.doDrag(dragInitiator, ds, event, dragProxy);

                  }

      And the drop handler:
              private function dragDropHandler(event:DragEvent):void
              {
                     var image:Image = Image(event.dragSource.dataForFormat("img"));
                     image.x = event.localX;
                     image.y = event.localY;
                     UIComponent(event.currentTarget).addChild(device);
              }
      What am I doing wrong that is causing this jumping?
      Thanks,
      -Mark