Copy link to clipboard
Copied
Hello, guys!
I would like to know how to correct the code to prevent "jump" of instance (Y coords) to initial Mouse Down position. What should I add?
this.L.y = 430;
this.L.on("pressmove", function(evt) {
let p = evt.currentTarget.parent.globalToLocal(evt.stageX, evt.stageY);
//evt.currentTarget.x = p.x;
evt.currentTarget.y = p.y;
if (evt.currentTarget.y > 730) {
evt.currentTarget.y = 730;
} else if (evt.currentTarget.y < 430) {
evt.currentTarget.y = 430;
}
stage.update();
});
Thank you!
Copy link to clipboard
Copied
Capture the X/Y difference between the mouse coordinates and the clicked symbol to a set of persistent variables, then subtract (or add) that difference when setting the symbol's dragged coordinates.
Copy link to clipboard
Copied
Sure, I have done this with mouseclick. Then mouse down. How to do this within one code block?
Copy link to clipboard
Copied
Bu the way, can you help me to understand how to put 'INCORRECT' movie clip straight to mouse coordinates? There are main window and inner movie clip. I want to get this "INCORRECT" opened only while click at panel_PA_anim with right coordinates.
Copy link to clipboard
Copied
I've fixed the problem in a such way. It works perfectly on iMac, but then doesn't work on iPad.
What's the problem?
createjs.Touch.enable(stage);
this.L.y = 430;
let offset = 0;
this.L.addEventListener("mousedown", (evt) => {
let a = evt.currentTarget.parent.globalToLocal(evt.stageX, evt.stageY);
offset = a.y - evt.currentTarget.y;
console.log('mouse clicked');
});
this.L.addEventListener("pressmove", (evt) => {
let p = evt.currentTarget.parent.globalToLocal(evt.stageX, evt.stageY);
//evt.currentTarget.x = p.x;
evt.currentTarget.y = p.y - offset;
if (evt.currentTarget.y > 730) {
evt.currentTarget.y = 730;
} else if (evt.currentTarget.y < 430) {
evt.currentTarget.y = 430;
}
stage.update();
});
this.L.addEventListener("touchstart",function(evt) {
evt.preventDefafult();
let a = evt.currentTarget.parent.globalToLocal(evt.stageX, evt.stageY);
offset = a.y - evt.currentTarget.y;
console.log('touched');
});
this.L.addEventListener("touchmove",function(evt) {
evt.preventDefafult();
let p = evt.currentTarget.parent.globalToLocal(evt.stageX, evt.stageY);
//evt.currentTarget.x = p.x;
evt.currentTarget.y = p.y - offset;
if (evt.currentTarget.y > 730) {
evt.currentTarget.y = 730;
} else if (evt.currentTarget.y < 430) {
evt.currentTarget.y = 430;
}
stage.update();
});
Copy link to clipboard
Copied
"Doesn't work" is uselessly vague. What exactly do you mean?