Skip to main content
Participant
January 23, 2021
Answered

pressmove give offset

  • January 23, 2021
  • 2 replies
  • 342 views

I'm trying to do a simple drag and drop using "pressmove."  The problem I'm having is that the object being dragged is only centered on the mouse pointer when it is a 0, 0 on the stage.  The further right I go, the more the object lags behind the cursor (object X  < cursor X).  The more down I go, the more the object lags in the Y direction.  So, it is perfect in the upper left-hand corner and totally off (~100 px) in both dimensions in the lower right corner.  What the heck?

 

var a17 = new lib.A17();
answer1Array.push(a17);
a17.addEventListener("pressmove", moveItem);


function moveItem (e){
e.currentTarget.x = e.stageX;
e.currentTarget.y = e.stageY;

    This topic has been closed for replies.
    Correct answer kglad

    try

     

    function moveItem (e){
    e.currentTarget.x = e.stageX/stage.scaleX;
    e.currentTarget.y = e.stageY/stage.scaleY;

    2 replies

    SlishdfAuthor
    Participant
    January 24, 2021

    Excellent!!!  Thanks!!!

    kglad
    Community Expert
    Community Expert
    January 24, 2021

    you're welcome.

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    January 24, 2021

    try

     

    function moveItem (e){
    e.currentTarget.x = e.stageX/stage.scaleX;
    e.currentTarget.y = e.stageY/stage.scaleY;