Skip to main content
Participant
January 23, 2021
Answered

pressmove give offset

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 is closed to new replies. Start a new post to keep the conversation going.
    kglad
    kgladCorrect answer
    Community Expert
    January 24, 2021

    try

     

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

    3 replies

    SlishdfAuthor
    Participant
    January 24, 2021

    Excellent!!!  Thanks!!!

    Translate
    kglad
    Community Expert
    Community Expert
    January 24, 2021

    you're welcome.

    Translate
    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;
    } 

    Translate